Hi everyone,

I’m trying to make a script that will stop the object from rotating when it reaches 90° and -90° on the X axis.

I’ve used the WorldOrientation method to do it. But it generates me a 3x3 Matrix. I wasn’t too sure how to use it so I converted it to Euler with to_euler() which makes more sense to me. After some tests I’ve determined that for my object to be inside the ±/90° limit it needs to be inside between -3.1300 and -0.0440.

So I made an if condition so that the object can only rotate up and down, well down not yet, but only up when it meets the prior condition. When it does then I activate a rotation with an actuators already set to rotate the object the way I need.

The problem is that when it starts moving it doesn’t stop. The whole purpose of my script was to stop the object from moving 360°. I want to make it stop when it goes beyond it’s limit. I’ve tried a while with the condition that the key is pressed, but then Blender crashed, so I’m not too sure what to do now.

Here’s my code so far.

```
from bge import logic
import mathutils
from mathutils import Matrix
cont = logic.getCurrentController()
obj = cont.owner
keyup = cont.sensors['KeyUp']
keydown = cont.sensors['KeyDown']
rotup = cont.actuators['RotUp']
if keyup.positive:
print(obj.worldOrientation.to_euler())
bob = obj.worldOrientation.to_euler()
print(bob[1])
if bob[0] < -0.0440 and bob[0] > -3.1300:
while keyup.positive:
cont.activate(rotup)
```

Thank you in advance for your help.