How to "set rotation" in the BGE using python.

So, like most python scripts I’m using ‘own’ as ‘GameLogic.getCurrentController().getOwner()’

I’m making a hand that floats in the air following the mouse and when you left click it slaps.
To do this I’m using ‘own.setPosition()’ and mouse co-ordinates, when you click it’s position is set a little bit further along the y axis and it is meant to rotate along the z axis, allthough I am stumped on how to do this.

I first tried ‘own.setRotation()’ because of setPosition(), but that didn’t work because it doesn’t exist, I then printed ‘dir(own)’ and saw ‘setOrientation()’, so I tried using that like this: ‘own.setOrientation([x,y,z])’, but got an error and now I have no idea where to go.

Was I using the right method wrongly or is there something else I should be using, and how am I meant to use it? Or do I have to use the motion actuator? (which I’d rather not).

You could use a motion actuator connected to your python controller.
Use “setDRot” to change it’s rotation. I’m not sure if this is what you’re after though.
Woot for Australian blender users. (WOOT!)

I was actually hoping I could do it without the motion actuator.

Hah yes. Are you from Melbourne? Because if you are, I think you need to visit this link

I wrote a tutorial that explains the BGE orientation matrix in detail:

If you can execute your rotation sequence with a motion actuator, then you should use a motion actuator.

Hah, after reading that I think I will use a actuator because I’m rotating 24 degrees.
Thanks for you help, I was hoping that setOrientation was a bit simpler then that though.

Or you could use IPOs.

PS. Hazaah for Aussies!

I second that :rolleyes:

LOL. It seems today anything can be fixed with an IPO.
The answer to the meaning of life is IPO!