x


Rotation returns normalized value?

I do a debug.log(transform.rotation.y) and it returns me a value of 0-1. How can I get the real rotation in degrees and not a normalized value? Thanks

more ▼

asked May 28 '11 at 10:29 AM

Johan 4 gravatar image

Johan 4
427 81 84 97

The rotations are Quaternions (a complex 4-dimentional representation of a rotation):
http://en.wikipedia.org/wiki/Quaternion
They have been invented to circumvent problems at certain angle-combinations. The 4 components of a quaternion have nothing to do with angles. Like iggy said you want the eulerAngles of the quaternion. The localEulerAngles are what you see in the inspector.

May 28 '11 at 12:12 PM Bunny83

Ironically, the "complex 4-dimentional representation of a rotation" is normalized, so the op was right! :p

May 28 '11 at 12:19 PM Joshua

@Joshua: sure, but i just explained what you have to expect from the x,y,z,w components. If you don't want to do some lowlevel calculations on them you normally don't need to access the components of a quaternion.

The point is eulerAngles represents 3 rotations that are executed in order z,x,y (or reverse depends on local/global) The point is that some angles like x==90 or -90 a the y and z rotation affect the same axis, therefore you have unlimited possibilities to represent the rotation. It's getting worse when you want to do a relative rotation. That's why Quaternions are awesome. You can do relative rotations from an arbitrary rotation to another arbitrary rotation.

May 28 '11 at 02:39 PM Bunny83

I know ^.^ I was just jokingly pointing out that they are indeed normalized. Anyway - to the OP: Don't touch them unless you understand them, and don't try to understand them unless you have at least an afternoon to waste. ;)

May 28 '11 at 03:28 PM Joshua
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

just type this:

debug.log(transform.eulerAngles.y);

more info on: http://unity3d.com/support/documentation/ScriptReference/Transform-eulerAngles.html

more ▼

answered May 28 '11 at 10:37 AM

iggy gravatar image

iggy
441 2 6

(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:

x1281
x288
x16

asked: May 28 '11 at 10:29 AM

Seen: 1303 times

Last Updated: May 28 '11 at 03:28 PM