- Home /
C# how to rotate an object back to its original rotation
I've been trying this but it never works, it just stays how it is and it doesn't give me an error code. the if statement for this is:
if (transform.rotation.z > 160f && transform.rotation.z < 200f)
{
}
it is supposed to be between 160 and 200 but i think i might have done the if statement wrong
Start by exa$$anonymous$$ing the behavior of those values. Just display them in the console and see what numbers you are getting and from there what numbers are needed for the desire you want.
Please post more of your script. Not sure what you are attempting with just this line.
What are you trying to achieve exactly?
One problem I can see is that you're using transform.rotation which is a Quaternion variable. You want to be using transform.eulerAngles which is a Vector3 and will allow you to clamp between 160 and 200 degrees.
Could you please give more detail and context on what you are trying to do?
Answer by Josh1231 · Jul 28, 2013 at 01:21 AM
don't worry, i fixed it by doing transform.eulerAngles
Answer by RyanZimmerman87 · Jul 28, 2013 at 12:55 AM
I would try out using Quaternion.identity that resets the position the only question is will this be the position you want to use, if not than you could probably apply some instant rotation or transform.position so that it does work like how you want.