playMaker

Author Topic: deltaTime and framerate question  (Read 3182 times)

troubleMaker

  • Playmaker Newbie
  • *
  • Posts: 25
deltaTime and framerate question
« on: January 13, 2015, 12:45:48 PM »
Hi,

How is "time" measured in Unity exactly? I used the Get time info- action to get the smoothed deltaTime, and got something like 0,0177, which would mean something like 58 frames per second, right? At the same time i was rotating an object 1 degree per frame with the Rotate- action, and had a Wait- action in the same state to finish off the state after 1 unit of "time". I thought this would be one second.

But the object rotates only 37 degrees. And not 58 like the framerate would lead me to believe. To confirm I even put an Int add-action to add 1 to a variable every frame, and once the state finished with the Wait-action the number was 37. I'm really confused now.

The above case was for debugging, but it's very important to me to understand how this works because i'm somehow trying to anticipate how an object will rotate(or move) in a certain period time at it's current speed. It's so i can put some lead into my targeting system.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: deltaTime and framerate question
« Reply #1 on: January 14, 2015, 03:13:18 AM »
Hi,

 frames delta time varies for each frame, and so if you want to rotate without being frame rate depedant, you will have to multiply your 1 degree by the delta time, and then you'll get a perfect rotation per seconds behavior, totally indepedant of the framerate.

http://unity3d.com/learn/tutorials/modules/beginner/scripting/delta-time

Bye,

 Jean