Adding * Time.deltaTime breaks my game

Oscillation is barely visible when I add in * Time.deltaTime to the offset variable value in the Oscillation.cs
i.e. Vector3 offset = movementVector * movementFactor * Time.deltaTime;

Similarly when I add it into the ApplyThrust function in Rocket.cs my rocket can’t move anymore,
i.e. rigidBody.AddRelativeForce(Vector3.up * mainThrust * Time.deltaTime);

it does still rotate even though I have this:
float rotationThisFrame = rcsThrust * Time.deltaTime;

Everything works when I remove it from the offset value and from in ApplyThrust().

Can anyone please advise? Thanks in advance.

I’ll try:

Time.deltaTime is the amount of time, in seconds, that it took the prior frame to render. If you are getting 30 FPS, that’s 1/30th of a second… a very small number… 0.0333…

Any # multiplied by a number smaller than 1 gives a smaller sum.

This is why we have “public float movementfactor”, so that we can hit Play, then use the tool in the inspector to find a movementfactor that is suitable.

My suggestion, change your movement factor. Maybe start by multiplying it by 30 or 60 (whatever you think your FPS is) and see if that’s what you expect. If not, start tweaking it in the inspector.

Good luck!

PS - to clarify, the entire reason for using deltaTime is to give all of your users a common experience. Consider the following:

I make a game that does not use deltaTime when moving objects in the physics-space. Player A has a high-end rig getting 90 FPS when he runs my game, and it takes my object 1 second to (for example) rotate 360 degrees.

Now Player B plays it on their nearly-dead-battery iPhone, and they get 30 fps… and it takes the same object 3x longer (3 seconds) to do the full 360 degree rotation…

If I’d used deltaTime in my rotation calculation, both players would see the same thing over the same time interval, instead of something so radically different.

Privacy & Terms