setOrientation

This has stumped me for a long time.I’ve done some research, but i can’t seem to find anything useful. I want an object to keep its rotation, using a python script. I wrote this bit of code:

g=GameLogic
cont=g.getCurrentController()
own=cont.getOwner()

own.setOrientation([0,0,22.5])

But i get this message:

PYTHON SCRIPT ERROR:
Traceback (most recent call last):
  File "Text", line 6, in ?
SystemError: error return without exception set

Does anyone have a solution? or a better method?
Thanks in advance.

you set the orientatin wrong…

is wants a list of three lists of three numbers

not a list of three numbers

yeah like


own.setOrientation(([1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]))

each list is how far each axis points in each direction so its like:
own.setOrientation(([Xx, Xy, Xz], [Yx, Yy, Yz], [Zx, Zy, Zz]))
thats what i got out of my experimentation

stelle it is a little differant it’s like

[[Xx,Yx,Zx],[Xy,Yy,Zy],[Xz,Yz,Zz]]

pretty sure

Edit: haha didn’t look at the name just the avatar to see who it was. why did you change your name from stella?

Thanks for the replies. So there’s no easy way to do that stuff without knowing lots of math,right? 'cos I’m just 13 and don’t know about vectors and matrices (i’ve only heard of them through herman tullken’s tutorial,which i just found). But i tried again and i got it to keep its orientation constant. So, thanks again,guys.

Do you need to do it with a python script? I think disabling the ‘Rigid Body’ button is what you need.

If you need to set a fixed orientation in python, get the current orientation this way:

print own.getOrientation()

It will print something like this

[[0.70928, -0.28742, 0.63634], [0.70928, -0.28742, 0.63634], [0.70928, -0.28742, 0.63634]]

Pass that to setOrientation().

You can also copy the orientation of an objecto to another this way:

own1.setOrientation(own2.getOrientation())

or if you use the orientation several times, this is more efficient:

myway=own2.getOrientation()
own1.setOrientation(myway)
own3.setOrientation(myway)
own4.setOrientation(myway)