Search code examples
c#unity-game-engine

Will this object be faster on a higher framerate, since it's in Update()?


I'm in Unity 2D using C#.

So, I know that normally putting a value that is time-based into Update() is normally bad, but will the same happen for a Rigidbody2D? I'm not sure, but it seems to calculate the rate itself...

Here is the code:

void Update()
{
    rb.linearVelocity = transform.right * velocity * 3f;
}

Will its speed differ, based on the framerate?


Solution

  • I wont differ because your code just changes the velocity of the gameobject. If velocity changes, speed changes but since transform.right * velocity * 3f is always same, velocity doesnt change, so speed doesnt change.

    You can try this yourself by going to game window, selecting resolution option then turning Vsync on or off. Enabling Vsync will lock your fps to 60, disabling it will increase your fps. Vsync option in game window

    You can see your fps from going to game window and clicking stats option Stats option in game window