x


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"?

more ▼

asked Feb 16 '11 at 09:12 PM

smweis gravatar image

smweis
3 2 2 5

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
more ▼

answered Feb 16 '11 at 09:46 PM

Jessy gravatar image

Jessy
15.6k 72 95 196

Thanks, that call gave me exactly what I needed, but to print it on screen target.eulerAngles.y.ToString() did the trick.

Feb 17 '11 at 04:14 PM smweis
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3668
x2155
x144

asked: Feb 16 '11 at 09:12 PM

Seen: 1030 times

Last Updated: Feb 16 '11 at 09:12 PM