I'm trying to move an object so that it moves visually at the same speed regardless of frame rate fluctuations. From my understanding, I should be using Time.deltaTime to determine how far to move during each iteration of Update. My Update code is like this:
void Update()
{
this.rigidBody.MovePosition(this.transform.position + new Vector3(Time.deltaTime * 2f, 0, 0));
}
However, the object moves in faster and slower spurts as it moves across the screen. If I move it a constant amount during each Update (like below), it appears to move evenly.
void Update()
{
this.rigidBody.MovePosition(this.transform.position + new Vector3(0.02f, 0, 0));
}
I'm confused because I thought that moving an object a constant distance during each Update should be the thing that causes jitter since its speed would be affected by the frame rate. And I thought that using Time.deltaTime should cause a constant rate of framerate-independent movement.
My Time.deltaTime values vary between 0.002 to 0.17, which I also don't understand because I have a very simple scene of only 2D sprites so I don't understand why the variance is so great.