Limit Rotation Blender Game Engine

Hey BlenderArtists,
I have a made a car, made out of 4 wheels attached to a body by rigid body constraints, and it works fine. The only problem is, if I go to fast and turn, or hit some kind of obstacle, it will turn/roll over and there is no way to get it back up and keep going. I know how to lock rotation, but I don’t want to do that because it doesn’t give me the right car effect I want. Does anyone know how to limit rotation, so an object won’t rotate all the way on a certain axis? Perhaps by code? I know there is a constraint that can do this but it doesn’t seem to work in BGE. Thank you!


keypress (flip)--------python

import bge

this will flip you back over I think.


flipDemo.blend (433 KB)

Thanks, but I really just don’t want the car to flip over at all. However this code does fix some other problems!

If RotXYZ.x > 90:
If RotXYZ.x <-90


NoFlip.blend (434 KB)

Thanks, but the wheels that are jointed to the body are having strange problems. Any fix for that, or maybe another solution?

yeah, apply torque instead of change rot,

this uses wrectified “TorqueTrackTo” and Force Move to,

but it needs updated, as I don’t know why I named anything the way I did

Torque = "“Force” to match a objects orientation

X1=Force to make a object move to another


OldWrectifiedScriptModified.blend (438 KB)