Rotate actor with accelerometer

KEE4KEE4 www.chriskieffer.comLos AngelesMember Posts: 65
edited November -1 in Working with GS (Mac)
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

  • forkliftforklift Member Posts: 386
    If you want to make the actor rotate right when moving right, and rotate left when moving left, try this:

    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.
  • KEE4KEE4 www.chriskieffer.com Los AngelesMember Posts: 65
    Thanks will try this and let you know. Also would this work for Y as well? I would just need 2 more attributes and do the same for the rest right?
  • forkliftforklift Member Posts: 386
    Yes, the same theory applies to Y movement (up and down). Here it is again with the values for Y.

    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.
  • KEE4KEE4 www.chriskieffer.com Los AngelesMember Posts: 65
    Thanks, I will let you know if it works. I appreciate the help and quick response.
  • forkliftforklift Member Posts: 386
    Heck, you could even try it like this in your rotating actor:

    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
Sign In or Register to comment.