- Home /
Time.time rotation going faster and faster
this is a line just to spin a spacecraft round and round as it files forwards. The trouble is that it spins slowly at the start of game, and then it spins faster and faster and goes crazy fast. I just want it to spin at a constant rate:
transform.rotation = steerot * Quaternion.AngleAxis(Time.time*0.5, Vector3.forward);
Answer by _met44 · Apr 18, 2014 at 08:41 AM
Try using deltaTime instead of time, this way you should get a constant speed. With time the value is small at the beginning but it keeps going up obviously and that gets your ship rotating faster and faster.
transform.rotation = steerot * Quaternion.AngleAxis(Time.deltaTime * 0.5, Vector3.forward);
hi met, Thanks, that's wrong though, because deltaTime is the time since the start of the last frame, it resets every frame.
I want the aeroplane to rotate through 360 degrees regularly over time, so Time.time sends AngleAxis angle 0-360, but it just goes faster and faster.
oh sorry i get the solution, the rotation is incremental anyway so if i call it for the same angle every frame it will increment over time.
transform.rotation = steerot * Quaternion.AngleAxis(30, Vector3.forward);
call it every frame
So you want to rotate 360 degrees over a defined duration but this is what you are given here.
Using:
Quaternion.AngleAxis(360f, Vector3.forward);
Will rotate 360 per frame.
Quaternion.AngleAxis(Time.deltaTime * 360f, Vector3.forward);
Will rotate 360 degrees per second
Now you can define your duration with
public float duration = 2;// Full rotation over 2s
private float f_duration = 1 / duration;
Quaternion.AngleAxis(Time.deltaTime * 360f * duration, Vector3.forward);
See if you give a value like 5 for 5s you get 1/5 -> 0.2 so each time your given value is reduced by 5. If you want to speed up the rotation, you give 0.5 for half a second then you get 1 / 0.5 -> 2, and this will multiply the value by 2 hence increasing the rotation per frame and reducing the duration of the rotation.
Your answer
![](https://koobas.hobune.stream/wayback/20220613143010im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotating around the Y axis then on Z axis makes my object rotate on the X axis 1 Answer
Instantiate objects faster and faster over game time,Instantiate objects faster and faster over time 1 Answer
Rotation question 1 Answer
How can i make my game go faster every 3 seconds? (Im not a Bot please answer me) 1 Answer
Quaternion.Slerp rotation speed increases over script life. 1 Answer