rotation degrees

hey guys,

I’m trying to access the rotation of a GameObject and have something happen when it hits 90, 180, 270… and so on. The problem is that when I checked to see what numbers I get, when I should have been getting 90, I was getting -0.7071068. I’m pretty sure I’m doing everything right… but not sure because this is only my 4th day with unity and second with C#.

Instead of giving you my whole C# script, here’s what I’m using to display the angle to me:

public class spheremovec : MonoBehaviour { 
public GameObject spin;

//I use this to display the received number
	public float script;
void  Update (){ 
script = -spin.transform.rotation.y;
}
}

oh, and the GameObject that I’m getting the data from displays the correct rotation degree change when I look at it while rotating.

thanks,
Matt[/code]

Hi Matt,

transform.rotation does not return an angle like you are after (a eulerAngle).

.transform.rotation.eulerAngles.y

will return what you require. Have a read up on ‘Quaternions’ in the Unity Docs and ‘Rotation’ for a better understanding on what rotation is returning.

Hope this helps.

Regards,
M.

thanks! that’s what it was =)