I want to rotate by 90 degrees every two seconds.
var rotate:float;
var one=true;
function Update()
{
Rotate1();
}
function Rotate1()
{
if(one==true)
{
one=false;
rotate +=90;
transform.Rotate(0,rotate,0);
yield WaitForSeconds (2);
one=true;
}
}
I want: – I see in Inspector.Transform.Position.Y
90 – 90.00001
180-- 270
270-- 180
360-- 270
450-- 90.00002
540—9.659347e-06
I have a question:
Why turnover is 90 degrees?
Why the addition of 90 degrees occurs 0.00001?
Why two seconds breaks are preserved only freely?
Thanks for reply
transform.Rotate rotates the object to current rotation + rotate.
current rotation + rotate
0 + 90 = 90
90 + 180 = 270
3 270 + 270 = 180, considering the wrap at 360° where it goes back to 0°
Your questions
I dont understand
That may becaused by float imprecision during the computation
I dont understand
Thanks for reply.
I change script:
var rotate:float;
var one=true;
rotate=90;
function Update()
{
Rotate1();
}
function Rotate1()
{
if(one==true)
{
one=false;
transform.Rotate(0,rotate,0);
yield WaitForSeconds (2);
one=true;
}
}
now working very well.
but 0+90 is 90 I have 90.00001
what is 0.00001
thanks for the explanation rotation.
I want change this red position on image.
Script:
transform.rotation.y=90;
but I have 178.7268
transform.rotation is a Quaternion… to get a 90 degree change you need to look at the Euler function
ar0nax
May 16, 2013, 11:58am
7
transform.rotation is a Quaternion, while in Inspector you see EulerAngles. use transform.eulerAngles in your scrip, and note that Unity modifies your rotation values sometimes to make sure it does not get Gimble-Locked (seach gimble lock on youtube for a better understanding).
transform.eulerAngles.y=90;
Thanks now it work.