Rotate actor with accelerometer
KEE4
www.chriskieffer.comLos AngelesMember Posts: 65
I already setup the movement with the accelerometer in portrait mode. I just need the actor to rotate the direction its heading. I tried a couple of things but havent gotten any results that were smooth. Any ideas would help thanks.
Comments
Have 2 game.attributes (boolean): game.goingRight & game.goingLeft
Rule: When self.linearvelocity.x > 1, set attribute game.goingRight = true
Otherwise when self.linearvelocity.x < 1, set attribute game.goingRight = false
Rule: When self.linearvelocity.x < 1, set attribute game.goingLeft = true
Otherwise when self.linearvelocity.x > 1, set attribute game.goingLeft = false
Rules in rotating actor:
When game.goingRight = true, rotate to angle (your angle of choice), set to SCENE instead of actor.
When game.goingLeft = true, rotate to angle (your angle of choice), set to SCENE instead of actor.
Have 2 game.attributes (boolean): game.goingUp & game.goingDown
Rule: When self.linearvelocity.Y > 1, set attribute game.goingUp = true
Otherwise when self.linearvelocity.Y < 1, set attribute game.goingUp = false
Rule: When self.linearvelocity.Y < 1, set attribute game.goingDown = true
Otherwise when self.linearvelocity.Y > 1, set attribute game.goingDown = false
Rules in rotating actor:
When game.goingUp = true, rotate to angle (your angle of choice), set to SCENE instead of actor.
When game.goingDown = true, rotate to angle (your angle of choice), set to SCENE instead of actor.
This of course is the long way to set things on and off (not using the otherwise statement to its fullest) but I wanted to illustrate the point so you can adapt it to your needs.
When self.linearvelocity.Y > 1, rotate to angle (in scene)
otherwise rotate to angle Zero
When self.linearvelocity.Y < 1, rotate to other angle (in scene)
otherwise rotate to angle Zero