- Home /
Question by
CretinousInvelid · Jan 18, 2013 at 03:07 AM ·
rotationrotate
How can i limit rotation in my script?
I need to stop an object from rotating after it has rotated a specific amount of degrees, how can I modify my code to do this? This is my code:
var target : Transform;
function Update() {
// Slowly rotate the object around its X axis at 1 degree/second.
target.Rotate(Vector3.right * Time.deltaTime*10);
// ... at the same time as spinning relative to the global
// Y axis at the same speed.
target.Rotate(Vector3.up * Time.deltaTime, Space.World);
}
help would be appreciated, thanks.
Comment
You can use Quaternion.Lerp. Give it an initial rotation, then a end rotation and how long you want it to travel. http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.Lerp.html
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Viewmodel/camera rotation when moving 1 Answer
Min, Max Rotation Help 2 Answers