Simple python question


I’m new to BGE python as you can probably tell.


So here my debug info from the shell:

    own.setOrientation[1.0 1.0 1.0]
SyntaxError: invalid syntax

What syntax do I have to use after setOrientation?

I hope my question is clear and thanks for reading.

edit: what exactly is Orientation? Is it rotation? Because there is “setPosition” and “setOrientation”. Position is XYZ location, so is Orientation just the rotation of the object?

Well, firstly you need parenthesis encapsulating any arguments you pass to a function:

setPosition( [x,y,z] )

Secondly, you need commas between any arguments you pass, see the above example.

And thirdly, orientation takes a 3x3 matrix not a 3D vector. Orientation is not rotation, orientation tells each axis of the object to point along a vector. A member here called Social explains the orientation matrix but I can’t find the link, you may have to ask him yourself.

P.S You are using pre 2.49 GE API, the 2.49 API for setting position/orientation is:

object.worldPosition = [x,y,z]
object.worldOrientation = [ [1,0,0], [0,1,0], [0,0,1] ]

Ooohh ok I get it. I was looking for documentation for setOrientation and couldn’t find it. I wondered what the new API equivalent of setOrientation was…

Thanks a bunch andrew.

edit: I tried out this code with some tweaks and it TOTALLY solved my problem. Thank you so much :smiley: