Be the first to post for 'Using Time.deltaTime'!

If you’re reading this, there probably aren’t very many posts yet. But don’t worry, you can be the first! Either create a new post or just reply to this one to say ‘hi’.

From what I understand (with a little help from the quiz), Time.deltaTime gives the time between the last frame and the current frame. Therefore, during the time between the current and next frames, the object’s transformation may be slightly more or less than what the later time would yield, but the difference is hardly noticeable.

Somewhere in the course Ben adds Time.deltaTime to the following line:

Rocket.cs -> ApplyThrust-> rigidBody.AddRelativeForce(Vector3.up * mainThrust * Time.deltaTime);
Adding time.deltatime leaves my ship grounded, while removing its flying normal again.

Any thoughts?

Give mainThrust a very high value. I set mine to 1000.

Close Christopher. More accurately, it’s the amount of time that passed before the most recent frame was rendered, and the frame that preceded that one was rendered. It’s a good way to guesstimate how much time will pass rendering the next frame, but it’s imperfect. Later We’ll probably be introduced to FixedUpdate(), quote “This function is called every fixed framerate frame, if the MonoBehaviour is enabled. FixedUpdate should be used instead of Update when dealing with Rigidbody. For example when adding a force to a rigidbody, you have to apply the force every fixed frame inside FixedUpdate instead of every frame inside Update.”


I learned that for some reason, my vectors are the opposite. So, for typing A, I had to write the code as transform.Rotate(-Vector3.forward) and I had to do the opposite for typing D.
Everything’s working though so I’m happy with my progress so far :slight_smile:

An interesting remark on the linked Wikipedia was that it is really hard to explain right-handedness and left-handedness in a 2D picture as people tend to flip the image. So I think that is something to keep in mind when working in 3D on a screen; not everything moves he way you expect.


What I’ve learned

Privacy & Terms