Why is a KX_GameObject.orientation a 3x3 matrix instead of just a [x, y, z] list?
Because orientation consists of more than just x, y, and z rotation angles. It also can be used to stretch/skew/scale objects, and means that it’s a much more flexible and mathematically correct function.
Ok, so how do I get the x,y, and z rotation from this?
You can convert the orientation matrix to a list of euler angles using Mathutils:
from Mathutils import Matrix orientation = object.orientation ori_mat = Matrix(orientation, orientation, orientation) ori_eul = ori_mat.toEuler()
The ori_eul will be more like how you rotate the object in edit mode.
Thanks a bunch.
I know its been awhile, but how would you get the Euler angle in 2.5 without mathutils?
You don’t need to import mathutils in this case, because own.worldOrientataion is already a mathutils Matrix in 2.5.
Now you can just do this:
Thanks again social, I was wondering where the new documentation was!