Blender 2.5 Rotating object with Python

How do you rotate an object with python? I cant find an answer anywhere.
Thanks.

Get the object, and apply a rotation.



from bge import logic

cont = logic.getCurrentController()
obj = cont.owner
obj.applyRotation([0, 0, 0.1], 0) # Rotate on the Z-axis by 0.1 radians (I think), on the global axis (that's what the last 0 does)

You can also change the orientation matrix directly, or convert it to a Euler for easier use, like this:


ori = obj.orientation.to_euler()
ori.z += 0.1
obj.orientation = ori
1 Like

Thank you! It works! :yes: