DEV Community

Khandokar Nafis Jaman
Khandokar Nafis Jaman

Posted on

Update vs Fixed Update? Unity3D

If you are a game developer, you are familiar with the terms Update() and FixedUpdate().
But many of us are perplexed about the difference. We all know, Update() is used when we need to update something in every frame.

` // Update is called once per frame
void Update()
{

}
Enter fullscreen mode Exit fullscreen mode

`
But there is some issue with the Update method.
Frame rate differs from device to device or game to game. In that case, if you use any physics method in Update methods, it will not perform appropriately. To get rid of that, we should use the FixedUpdate method.

`
private void FixedUpdate()
{

}
Enter fullscreen mode Exit fullscreen mode

`

The FixedUpdate function runs at a fixed interval independent of your game’s frame rate so that our function works in every fixed frame. So when we need to use Rigidbody, we need to use FixedUpdate(). Such as, move the player or add force.

Happy Coding!!

Top comments (0)