Setting velocity _directly_ in FixedUpdate or Update?

I’ve been googling this for quite a bit and the usual recommendation I see is to do stuff “that applies forces to the Rigidbody” in FixedUpdate because different frame rates could lead to Update being called a different amount of times per second, causing methods like AddForce to be called a different amount of times depending on the system.

But what I could not clarify: Is this also the case when setting the velocity directly? As far as I understand, rb.velocity = doesn’t add up like AddForce does. So shouldn’t it be framerate-independent by nature even if used in Update?

private void Update()
    {
        dirX = Input.GetAxisRaw("Horizontal");
        rb.velocity = new Vector2(dirX * moveSpeed, rb.velocity.y); // Can I do this in Update?
    }

Your intuition that there would be zero difference is almost correct. In practice it might be an undetectable difference, but there still could be a difference, due to mismatch in call rates between those two. Here is why:

This is my favorite Unity3D diagram on timing:

Good discussion on Update() vs FixedUpdate() timing:

https://jacksondunstan.com/articles/4824

1 Like

Thank you very much! I’ll work through the links you provided!