Rotation in inspector changes on play???

I’ve been trying to retrieve certain angles with no luck.

In the pic below, figure A has a value of -25, as you can see B has 335.

On play the value is changed from -25 to 335, I know what’s happening but I don’t know how
to retrieve the values from figure A during run-time.

I am trying to determine when the rotation degree is 540, or -540 etc, figure A does this perfect… but figure B only displays 360. (Not even -360).

38984-rot.jpg

Help would be greatly appreciated!

Cheers, Tim.

This happens as Unity is nice and allows you to use minus values in the editor for rotations, but internally that cant be the case, the rotation is stored in something called an Quaternion, very complicated things that represents rotation. In the editor we see the Euler values, which are a simple way for us to see the rotation.

Basically at run time unity takes the values given and if they are minus, converts them to a rotation from 0 to 359. If you really require this minus value, you can do some simple maths to convert it, or take a look at the Transform class or Quaternion class

You could try something like:

float otherRotationValue;
otherRotationValue = (360 - transform.rotation.eulerangles.z) * -1;
//The times minus 1 at the end makes the value negative.

Edit: Thanks owen, i forgot to add eulerangles in!