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
0
Question by silverpendulum · Mar 04, 2013 at 10:56 AM · deltatime

Shouldn't deltaTime be defined as the 1 over the time interval between two frames?

I tried to consider it like this:

Suppose an object moves 3 meters between one frame and the next, and it takes 2 secs. If you multiply them directly like in the reference example, it gives us 3 meters/ frame 2 secs /frame = 6 meters sec / frame^2, whereas what actually occurs is it moves 3 meters in 2 seconds, that is 3/2 = 1.5 meters/second.

Also, why is it that in the example, 10 meters/frame retained its magnitude to 10 meters/second?

Comment
Add comment · Show 3
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 Fattie · Mar 04, 2013 at 12:29 PM 0
Share

it's called "TI$$anonymous$$E". why would it be 1/time ?? 1/time is something like Hz.

avatar image silverpendulum · Mar 07, 2013 at 05:44 PM 0
Share

There's this code snippet that goes Input.GetAxis("Horizontal")Time.deltaTime*5 And so if you multiply the Input part (which is in meters/frame) and Time.deltaTime (which is seconds/frame) you would get meters sec / frame^2 , which is not the wanted meters/second. :)

avatar image Fattie · Mar 07, 2013 at 07:02 PM 1
Share

sure dude, you're right. a really senior developer from Unity and sundry top ten Unity programmers have never thought this through.

Also all the text books on eg. arithmetic are wrong and the people people at the ISO and SI institutes missed that one.

Great work

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Graham-Dunnett · Mar 04, 2013 at 11:05 AM

The script example is correct. Time.deltaTime is definitely a time, and is the time between this frame and the last frame. So, if you were rendering at 100fps, then deltaTime would be 0.01s. In the example the object is moving at 10m/s. It's not accelerating, just has constant velocity. So, if you multiply deltaTime (a time) by a velocity (in metres per second) you get a distance in metres, which is how far the object moved in that time.

I didn't fully understand your math, but possibly you're making things more complicated than it needs to be.

Comment
Add comment · Show 2 · 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 Bunny83 · Mar 04, 2013 at 11:42 AM 0
Share

right, one over the time interval between two frames gives you the "frames per second". deltaTime allows you to work with "real" units like m/s. So everything is time-based.

avatar image silverpendulum · Mar 07, 2013 at 05:46 PM 0
Share

Yes, although how is "meters/frame" translated to "meters/second" by multiplying deltaTime? :D

avatar image
2

Answer by Chronos-L · Mar 04, 2013 at 11:47 AM

 distance, d  = 3 meters    
 time, t = 2 seconds    
 deltaTime, x ( the time need for 1 frame to show )



Your first equation is wrong to begin with. Let's do this calculation to see why(based on your first equation)

 Velocity = 3 meters/ frame * 2 secs /frame

 Let frame be 1 
 // I don't care what frame is right now, deltaTime, 
 // or number of frame per second, it doesn't matter

 Then,

 Velocity = 3 meters/ 1 * 2 secs /1
          = 6 meter * 1 second

What does 6 meter * 1 second means? It is meaningless, it is definitely not velocity ( meter per second ), nor can it mean anything else.

Further Inspection

hen you move 3 meters in 2 seconds, your velocity, V is

 V = d/t
 V = 3 / 2
   = 1.5 meter per seconds



When you said d/x (3/frame), this is not related to the original question at all, you are saying that

 distance travelled per delta time

So, you are now talking about the speed required to travel 3 meter per 1 frame

 If we are running 25 fps, deltaTime = 1sec/25frame = 0.04 seconds
 d/X = 3 meter / 0.04 seconds
     = 75 meter per seconds



Your second part is 2 sec/frame, which is t/x, which translate to

 2 seconds divides by time required to finish 1 frame

which will become, total number of frame in 2 seconds

 If we are running 25 fps, deltaTime = 1sec/25frame = 0.04 seconds
 t/X = 2 seconds / 0.04 seconds
     = 50 frames
Comment
Add comment · Show 3 · 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 silverpendulum · Mar 07, 2013 at 05:42 PM 0
Share

"Your first equation is wrong to begin with." Yes, I based this on the pdf tutorial which goes

Input.GetAxis("Horizontal")*Time.deltaTime*5

It was said that the Input part was in meters/frame, and the definition of time is seconds/frame, and so I wondered how it became meters/second when you multiply the two. :)

avatar image silverpendulum · Mar 07, 2013 at 05:50 PM 0
Share

In this scenario, hasn't the fps already been set to 1/2 (since it took 2 seconds from one frame to the next, i.e., 2s = 1 f or 1/2 s = 1 f) ?

avatar image Chronos-L · Mar 08, 2013 at 01:34 AM 0
Share

I am not sure about *Input.GetAxis("Horizontal")*Time.deltaTime*5*, so I am not giving any comments.

When you said In this scenario, hasn't the fps already been set to 1/2 (since it took 2 seconds from one frame to the next, i.e., 2s = 1 f or 1/2 s = 1 f) ?. Which scenario you are referring to? It has been 3 days, so I sort of lost track of my thoughts when I answered this question.

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

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What exactly is in Touch.deltaTime? 1 Answer

Jumpy object movement and camera movement 1 Answer

Using Time.DeltaTime doesn't result in framerate independence 1 Answer

Would this code not work because there is no Time.DeltaTime? 1 Answer

How can I keep "notes" in sync with music? 0 Answers


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