Constraining rotation
tekkendp
Member Posts: 49
Hi guys,
Looking for a bit of advice. I'm trying to use the accelometer to rotate an actor left or right. The problem is that I need to restrict how much it needs to rotate. The actor is pointing straight up, I want to rotate or lean left or right by a maximum of 45 degrees.
I can get the rotation part working, but I'm having a problem stopping the rotation to just -45 or +45 degrees.
Any tips?
Cheers.
Looking for a bit of advice. I'm trying to use the accelometer to rotate an actor left or right. The problem is that I need to restrict how much it needs to rotate. The actor is pointing straight up, I want to rotate or lean left or right by a maximum of 45 degrees.
I can get the rotation part working, but I'm having a problem stopping the rotation to just -45 or +45 degrees.
Any tips?
Cheers.
Comments
max(-45,min(45, angle))
where "angle" would actually be your current way of getting the number. Maybe it would be like this:
max(-45,min(45, game.Accelerometer.Z *100))
Thanks again.