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?
}