I have recently stuck up on problem where I have to set object's x and y rotation to 0.0, but keep z rotation equal to the current one (best way- don't affect at all). How to do that?

I was thinking of something similar to that what I used for other data(own.worldOrientation[0] = 0.0), but it didn't appear to work!

cont = bge.logic.getCurrentController()
own = cont.owner

#Set orientation to euler!
orientation = own.worldOrientation.to_euler()
#Set up orientation of each axis
orientation.x = 0.0
#Apply rotation
own.worldOrientation = orientation

Here is the code that resolves the problem! It absolutely works


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.