- Home /
90 degrees rotation and then back to 0 again after a 3 second delay
im very new to unity and ive gotten it to turn continuously... but i cant get it to stop at 90 degrees
Here is my code:
var right = true;
function Update () {
if (right)
{ rotation = 100.0; transform.Rotate (0,0,rotation * Time.deltaTime); }
}
Answer by HolBol · Oct 29, 2010 at 11:53 AM
You could use the animation view instead and script using animation.Play()
Answer by TheDemiurge · Oct 29, 2010 at 12:18 PM
use transform.eulerAngles
or transform.localEulerAngles
.
var resetDelay: float = 3.0; var lastResetTime: float; var idle: boolean;
function Update() { // assumes Z rotation was 0 to begin with if (idle) { var curTime: float = Time.time; if (curTime > lastResetTime + resetDelay) { lastResetTime = curTime; transform.eulerAngles.z = 0; idle = false; // comment this one out if you only want to reset once } else { transform.Rotate(0, 0, 100 * Time.deltaTime); if (transform.eulerAngles.z >= 90) idle = true; } }
Your answer
Follow this Question
Related Questions
Side scroller - rotate object towards player. 1 Answer
Character rotation help needed. 1 Answer
Rotating towards the mouse. 0 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Rotate to facing direction 6 Answers