Simple python

Whats wrong with this script? Basically, i’m trying to pin the Z-axis rotation in a game.


scene = GameLogic.getCurrentScene()


controller = GameLogic.getCurrentController()


object = controller.owner


################################


or_x = object.worldOrientation[0]


or_y = object.worldOrientation[1]


object.worldOrientation = [or_x, or_y, 0]

Describe your problem at least, or how are we supposed to give you a solution?

Why not use the constraint actuator?

Rotation and location axes can be locked from the logic panel > Advanced.

I’ve found that editing orientation matrices can get messy, since changing one of the vectors doesn’t necessarily change the others (many times it will deform the object). What’s technically wrong with the script is that the third item needs to be a vector like the other two are, or something like [0,0,1]. But I’d recommend going with one of the easier way to lock a rotation axis.

Yea just use a constraint actuator set on orientation with Z axis…its much easier than doing that…also I think that you should have used the alignAxisToVect(vect) method instead of the orientation thing.

But the constraint actuator doesn’t work. Iv’e tried it.

Anyway, locking it in the advanced panel worked, so thanks to musicaljelly.

Cheers.