
This is because as the frame rate is lowered the time since last frame actually increases and visa-versa for lower frame rates. We can use the time since last frame (deltaTime) to instead move the ball by (deltaTime * speed) pixels per frame which will make the ball always travel the same distance over the same amount of time, moving at a consistent speed. If the game is running at 10 frames per second (you can never be sure what frame rate you game will be running at on all systems!) then the ball will move 10 pixels in 1 second, meaning it’s moving 10 times slower! If the frame rate of the game is 100 then the ball will have moved 100 pixels in 1 second. Lets say you have a ball moving across the screen at 1 pixel per frame. how does the deltaTime help me with slower movement? You will want to use deltaTime movement in combination with either lerping or a interpolated rigidbody! (Both explained in their sections below!) But wait. Note: Using only deltaTime alone may still give stutter at lower framerates or at higher movement speeds. Unity has a variable named deltaTime (ltaTime) which gives the time in seconds since the last Update() call as well as fixedDeltaTime (Time.fixedDeltaTime) which is the constant time since the last FixedUpdate() (Which is a consistant value changed in the time manager or directly changed via script, but it’s handy to have) (Tip: Using ltaTime inside a FixedUpdate() will give you the fixedDeltaTime value) Otherwise when the frame rate of the game changes, the speed of the objects will also change! Moving objects based on frame rate is very important for creating smooth movement. position of a moving object per frame will create a lot of stuttering.Īdapting movement to the framerate with deltatime
Unity for mac low framrate code#
Try adding some debug logging to make sure the movement code isn’t being called multiple times – if not disable it and make sure no others scripts are moving the object! Multiple pieces of code trying to move the same object at once.Scale of the object you’re trying to move is either massively too big or very tinyĪim to keep your your objects based around a 1, 1, 1 scale.

Less common issues which I’ve seen in the past: The physics timestep is the amount of seconds between each physics update, if this value is set too high it can result in jittery movement


Script not taking frame rate into consideration when moving an object without a rigidbody.Īn object being moved 1 pixel per frame would jump and change speed as the frame rate changes!.
Unity for mac low framrate how to#
This guide explains the different options for smooth movement and explains what lerping and deltatime are as well as how to use them! (Very important and useful to learn when developing Unity games) Possible causes for movement jitter Not using a rigidbody:

There are many causes for objects to stutter when being moved in Unity.
