- Home /
Displaying the Y-value of the transform for the main camera
I need a way to display as a GUI text the Y-value for rotation of the main camera with the mouse.
I apologize for lack of coding knowledge, but this is a very simple way to do it, I just can't get it to work:
var target : Transform;
function Update () { var angle : float = Quaternion.Angle(transform.rotation, target.rotation); }
function OnGUI () {
GUI.Label (Rect (10, 10, 100000, 200000), target.rotation.ToString());
}
The problem I'm having is that I can display the vector values for the quaternion, and they change as my mouse rotates (0, 1, 0, 0) for 0 degrees, (0, -1, 0, 0) for 180. But how do I just display "0", or "180"?
Answer by Jessy · Feb 16, 2011 at 09:46 PM
target.eulerAngles.y
No need for ToString().
http://unity3d.com/support/documentation/ScriptReference/Transform-eulerAngles.html
Thanks, that call gave me exactly what I needed, but to print it on screen target.eulerAngles.y.ToString() did the trick.