- Home /
Question on Unity Documentation
Hi,
In the following link : Transform.Rotate
in the function
function Rotate (axis : Vector3, angle : float, relativeTo : Space = Space.Self) : void
the example is using Time.deltaTime as the angle. I am not able to understand why are using Time.deltaTime as the angle ?
Can anyone plz explain ?
Answer by Bunny83 · Jun 05, 2012 at 01:52 PM
Rotate rotates by a relative angle, since you usually do a continous rotation every frame (in Update) you only rotate a small amount each frame. Time.deltaTime is used to make the rotation speed independet from your framerate.
where are we specifying the angle ? Time.deltaTime is actually used to make the rotation speed independent of frame, but to the angle specified, here we are not specifying the angle all..
The Documentation says: Rotates the transform around axis by angle degrees.
Well, Rotate actually does that, but inside the Update function, and specifying Time.deltaTime as the rotation angle, it will rotate every frame that set amount of angle (so it will get a constant rotation for that object).
So, to summarize, we are rotating that game object by a very little value every frame, so it continuously rotates (like a planet does, for example), and this value is Time.deltaTime so the rotation speed doesn't depend on the framerate.
$$anonymous$$aybe you'll understand it more clearly that way :
transform.Rotate( Vector3(Time.deltaTime, 0, 0) );
Does Time.deltaTime actually store an angle in it ? or does it calculate the angle based on the framerate and the seconds ?
Finally i got it ! ..It's like the value of Time.deltaTime is acting as the angle value. :)