Full 360 Accelerometer Rotation Question

BlackbirdStudiosBlackbirdStudios Member Posts: 493
edited November -1 in Working with GS (Mac)
Hey guys,

So I am working on a game and I want the actor to be able to turn all 360 degrees based on the accelerometer position. (meaning its rotation can be anywhere from 0-360 degrees) Can I do this with one simple equation or will I have to configure individual equations based on different accelerometer positions?

Any help appreciated

Thanks,

-Matt

Comments

  • BlackbirdStudiosBlackbirdStudios Member Posts: 493
    BUMP, anyone help?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Are you looking 'one simple equation' to get the accelerometer data?

    make a game level attribute: accelAngle (real)

    In a timer:
    Change Attribute: accelAngle To:(vectorToAngle(game.Accelerometer.X,game.Accelerometer.Y)+90)%360

    The "+90" is for landscape mode ( change as necessary)
    The %360 is to make sure accelAngle does not end up higher than 360 (especially if 90 degrees gets added to it.)
  • BlackbirdStudiosBlackbirdStudios Member Posts: 493
    RThurman said:
    Are you looking 'one simple equation' to get the accelerometer data?

    make a game level attribute: accelAngle (real)

    In a timer:
    Change Attribute: accelAngle To:(vectorToAngle(game.Accelerometer.X,game.Accelerometer.Y)+90)%360

    The "+90" is for landscape mode ( change as necessary)
    The %360 is to make sure accelAngle does not end up higher than 360 (especially if 90 degrees gets added to it.)
    And where should this be inserted in the game? As the rotation for the actor?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Oh -- I see what you are asking now. (I was answering a slightly different question.)

    Yes -- sort of. In an actor put the following constrain behavior:

    Constrain attribute: (self.Rotation) To: (vectorToAngle(game.Accelerometer.X,game.Accelerometer.Y)-90)%360)

    Its a little jerky doing it that way but it might do.
Sign In or Register to comment.