Quantcast
Channel: von Lehe Creative
Viewing all articles
Browse latest Browse all 15

Unity Tip: Rigidbody Interpolation

$
0
0

Unity LogoWhen Intergalactic Sheep Pong was first published, I noticed some choppiness when the game was running in Firefox. The graphics would hang and then suddenly unfreeze, revealing objects in new, sometimes drastically different positions.

This was especially befuddling because in the Unity3D editor, I was getting framerates upwards of 1000fps. And in other browsers (such as Safari) the graphics were smooth.

The solution turned out to be simple: I enabled interpolation for the rocket and the sheep rigidbodies. Viola! The jittery behavior disappeared.

Interpolation involves smoothing the motion of objects. In Unity3D, interpolation is used to hide the fact that physics and graphics run at different rates. In some cases, this graphics/physics difference may be so small it’s unnoticeable. But in others, the differences can be so dramatic that the gameplay is hampered. If you’re seeing jerky, choppy behavior in an otherwise well-performing game, you might want to give interpolation a try.

You can read more about rigidbody interpolation here.

EDIT: Since I wrote this post, I’ve learned a bit more about framerate issues.

  1. The frames-per-second (FPS) shown in the Unity Editor stats window is not the actual framerate. It only reflects the time required to draw the graphics. Use this script to see the actual framerate.
  2. If you have fast-moving objects, you might want to use Time.smoothDeltaTime instead of Time.deltaTime.
  3. A couple other parameters that can be used to control choppiness are targetFrameRate and “Sync to VBL”.


Viewing all articles
Browse latest Browse all 15

Trending Articles