Constraining rotation

tekkendptekkendp Member Posts: 49
edited November -1 in Working with GS (Mac)
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.

Comments

  • CoIinCoIin Member Posts: 197
    In the expression entry field you can place some Math things. The entry would look like this:

    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))
  • tekkendptekkendp Member Posts: 49
    Thanks Colin. I have managed figure it out. I was making the mistake of making the rotation linked to the actors position, instead of in relation to the scene. It's working great now.

    Thanks again.
Sign In or Register to comment.