Unity: Update vs Fixed Update

Recently I created an Unity 2D project, and recently came into issues with my project once I loaded the project to my laptop. My laptop isn’t anywhere as good as my desktop, therefore very often I would run into frame issues where instead of normal 60 frames per second, I would have around 20–30 frames per second. This has caused my project multiple issues such as objects moving slower than others, while certain other effects will appear normally. Once I did some quick search I found a chart that outlines the order methods are called during a single frame in Unity and learned there was something called Fixed update.

image from Unity documentations

Update is the most common used function in Unity. It is called once per frame on any script that uses it. Anything that needs to be changed or adjusted will need to happen in this function. Therefore my codes for input, movement and timers are kept here. However the issue comes if one frame takes longer to process than the next, the time between update calls will be different.

Fixed update is similar to update except that it’ll have the same time between calls. This ensures that even if due to hardware issues, there is delays and leading to lower FPS, the fixed update will still be called within the same amount of time. So anything involving movement such as ridgidbody or physics should be placed in this function.

using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour
{
void FixedUpdate()
{
Debug.Log("FixedUpdate: " + Time.deltaTime);
}

As a test I checked the time between different calls inside an empty Unity project, and immediately noticed the difference. Inside Fixed Update, the time between calls is always 0.02, while for Update function, the time varies between 0.01 to 0.3.

I hope this information will be useful to anyone learning Unity or trying to build project on it for the first time.

Just a student at flatiron