- Home /
Question by
Thet Naing Swe · Oct 25, 2010 at 04:53 PM ·
objectrotateangledegrees
rotate the object only 360degree for once
How can I rotate my Object 360 degree once from code.
euler.z = 360.0f;
Quaternion rot = Quaternion.Euler(euler);
transform.rotation = Quaternion.Lerp(transform.rotation, rot, 0.1f);
and it doesn't work...
Comment
Best Answer
Answer by lhk · Oct 25, 2010 at 06:25 PM
I'm sorry but I don't understand your question. If you rotate something 360 degrees, you could simply not rotate it instead. 360 degrees are one complete turn. If you want to rotate it gradually around 360 degrees you should specify the code you posted. What kind of variable is euler ? Where did you insert this code ? Assuming, that you've written this in the Update function, you could try this c# code instead
float rotationleft=360;
float rotationspeed=10;
void Update()
{
float rotation=rotationspeed*Time.deltaTime;
{
rotationleft-=rotation;
}
else
{
rotation=rotationleft;
rotationleft=0;
}
transform.Rotate(0,0,rotation);
}
Thanks for the code it really helped me and saved me time !
Answer by Perfecter · Feb 08, 2015 at 08:19 PM
float rotationleft=360;
float rotationspeed=10;
void Update()
{
float rotation=rotationspeed*Time.deltaTime;
if (rotationLeft > rotation)
{
rotationleft-=rotation;
}
else
{
rotation=rotationleft;
rotationleft=0;
}
transform.Rotate(0,0,rotation);
}