How to fix movement stutter in Unity

In by John FrenchPublished

Generally speaking there are three reasons why movement in Unity will stutter.

  1. Viewing the game in the editor, not the standalone player
  2. Moving using physics (without interpolation enabled)
  3. Detecting input using Fixed Update instead of update

1. Viewing the game in the editor, not the standalone player

While. previewing the game in the editor is usually the easiest way to do it, movement and other parts of your game are likely to perform worse due to the increased overhead of running the game inside of another application.

In most cases, your game will run significantly better in the standalone player so, if your movement, or other parts of your game, are stuttering, it can be useful to check first if a build of the game experiences the same problems.

2. Moving using physics (without interpolation)

Physics-based movement is calculated in time with the physics timestep, which runs at a rate of 50 frames per second by default.

This means that any physics based movement will appear slower than update-based movement, which is likely to be running at 60 frames per second, depending on the performance of your game and the display.

This can cause jerky physics movement, which is particularly noticeable on player characters, or on physics objects that have a camera attached to them.

The solution is to enable Interpolation on the physics object’s rigidbody, which will smooth the movement of the object in between physics steps, in sync with the game’s framerate. This can be performance intensive, so it’s generally recommended to only do this on objects on which it is most noticeable.

An alternative method is to decrease the physics time step so that Fixed Update is called more often than Update is. However, while this does work, this is generally a less efficient solution, unless you also want to increase the accuracy of the physics simulation.

See also:

3. Detecting Input using Fixed Update instead of Update

For the same reason that physics-based movement can appear to be jerky, physics-based input can also feel like it stutters if it’s detected in Fixed Update instead of Update.

This refers to the old Input Manger method of detecting input where checks are typically made in Update to see if an input has been received.

However, when moving an object using physics forces, which usually takes place in Fixed Update, you may choose to also place your input checks in Fixed Update as well, alongside the movement code.

This can cause an issue as Fixed Update is typically called at a different frequency to Update, meaning that Fixed Update calls may be called more or less often that Update, and sometimes, not at all, depending on the difference in frame time between the two.

This can cause missed inputs, leading to jerky, inconsistent, movement.