Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Psychlade · Oct 19, 2011 at 08:43 AM · timerendertime.deltatimeframes

How does deltaTime exactly help faster computers?

This may seem like an easy question, but for some reason it caused me to rethink for a moment. I've searched through previous questions, and none of them really explained exactly how this works. I was reading through the Unity 3D Scripting tutorial, and came across the input part:

To accept input, you simply have to get the Axis your trying to move, and the game will render your input onscreen in the form of, well, movement. This goes like this:

transform.Translate(Input.GetAxis("Horizontal", 0, "Vertical"); ///// This makes perfect sense. But when it started talking about Delta Time, this was added: ///// transform.Translate(Input.GetAxis("Horizontal")*Time.deltaTime*speed, Input.GetAxis("Vertical")*Time.deltaTime*speed);

So, as far as I can tell, your essentially getting a copy of the amount of time since the last frame was rendered, then multiplying it by the actual speed at which you want to move the GameObject. This threw me off. How could doing this help framerate on faster computers? If anything, wouldn't it make the frames render too quickly?

Here's an example:

  1. Player presses Right Arrow(1)

  2. 1 is multiplied by Time.deltaTime(let's say, half a second for a slower computer)

  3. .5 is now multiplied by the actual speed you want to go by

Maybe I'm looking at this from the wrong angle, but wouldn't this mean that the time since the last frame rendered would be greatly increased for the next rendering?

speed = 3.0 .5 * speed = 1.5

This would help slower computers, but I don't see how it wouldn't hurt faster ones. I've searched this entire site for help, but have only found questions regarding what deltaTime is, and inconsistencies while using it. I may just be overthinking this, so I'm sorry if it's a large question if it's only a little thing, but I suppose it'll help anyone else who gets confused, right? :)

Here's the tutorial, by the way: http://docs.google.com/viewer?a=v&q=cache:L0rj1P77eCUJ:download.unity3d.com/support/Tutorials/2%2520-%2520Scripting%2520Tutorial.pdf+unity3d+scripting&hl=en≷=usπd=bl&srcid=ADGEESgdC23JeXBrRnne7-YJ6CGvHbg8cHOP7ATlQ64M0lndvVVfPYRKDoCZxga-5rwFpu9qP_aZhxpuG2PrhR_QU_VW1BKX4kExYRIDYa-k4FPSrX4R2OLup33c6vRm5Mi4P6rACzlL&sig=AHIEtbRsIkEXbtUVum-Kc-R-MGSfnArVaQ

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by syclamoth · Oct 19, 2011 at 08:54 AM

I think you're misunderstanding what the word 'help' means in this case. The point of multiplying all your values by deltaTime is to make sure that numbers for force, transformation, rotation etc. are framerate-independent, which is to say that in one second, an object will move the same distance (given a per-update translation) whatever framerate the computer is rendering at.

Using deltaTime does not affect framerate in any way except one- it will slow things down a very very very small amount because of that one extra multiplication in there. I should mention that the difference is extremely small.

An example would be, if your game was going at 2 frames per second, and you wanted an object to move by 6 units per second. In your Update function (which gets called exactly once per frame), you would multiply the distance (6) with the amount of time in the previous frame (in this case, about 0.5 seconds). This way, in ever one of the two frames ever second, the object will move 3 units- which add up to 6 every second.

However, when you turned the graphics settings down because you didn't like that slideshow, the framerate went up to a good amount like 60. In this case, the deltaTime will be something more like 0.016 seconds- when you multiply 6 by that, you get 0.1. Then, every frame, your object will move by 0.1 units, and then over 60 frames it will have moved 6 units, like you wanted!

Let's look at it from the other side. If you didn't use delta time, on your slow computer you would move by 12 units per second. However, on your fast mode, you'd be moving at 360 units per second!!

Basically, using deltaTime is not for performance optimisation, it is about game simulation accuracy and consistency. You can never know at compile time how long it will take between frames, so deltaTime allows you to take framerate into account when you are attempting to move an object (or do anything, really) at a constant rate.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Psychlade · Oct 19, 2011 at 09:50 AM 1
Share

I don't even know what I was thinking. Thank you for clearing this up for me, I believe I mistook the statement to mean it would just render everything faster. I suppose this is another reason why not to try to comprehend code when your tired from exams. :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

difference with Time.time, Time.deltatime, Time.frameCount 3 Answers

How do you add a time delay to this script ? 2 Answers

RigidBody MovePosition code acts differently by framerate 1 Answer

Null Reference Exception - Time.deltatime problem 1 Answer

Want to load scene after taking off in plane. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges