GameObject Movement Stuttering

I have a major problem with stuttering of movement with all GameObject.

  • The framerate seems to be fine: from 35 to 70 fps.
  • The stuttering happens both in Unity editor (fast computer) and when testing with any of my 3 Android test devices.
  • I measured the change per frame for transform.position.y/Time.deltaTime and it seems to be very much constant.
  • I have tried different sizes of sprites. I have tried sprites with width and height 2^X and 2^Y, where X and Y are constants.
  • I tried with sprites and 3D objects.

I have tried moving the GameObjects with the following ways:

  • transform.position=new Vector3(transform.position.x, transform.position.y+Time.deltaTime*speed, transform.position.z);
  • Adding a kinematic RigidBody2D to the GameObject and setting constant speed.
  • Making linear movement animation.

All of these result to the same stuttering problem.

I attached a simplified test project to this message.
I have tried Unity 5.1.1f1 and 4.6.7f1.

Could someone, please, test if they have the same problem?

It is a good idea to also use Lerp for moving objects. It causes the object to mathematically reach its destination very smoothly.

Here is an example:

void Update()
{
Vector3 newPosition = new Vector3(transform.position.x, newYPosition, transform.position.z);
transform.position = Vector3.Lerp( transform.position,  newPosition, speed * Time.deltaTIme);
}

you are determining the new position that the object needs to be sometime in your code/
You are constantly lerping the transform’s current position to the new position.
Every update, the object gets closer and closer to its final destination.
This allows a smooth position change
It’s important to remember that the object position might never reach the target position, so you need to remember that mathematically it never really reaches it’s final destination, but it will be very close (ex: 0.001).

Also, if your just starting a game and only getting 35 FPS, then something is definitely wrong with your code. You are probably doing things in update you shouldn’t. Can you post your update routine?