Accelerometer rotation

FanStudioUKFanStudioUK Member Posts: 459
edited November -1 in Working with GS (Mac)
Hi guys,

Can someone help me with an accelerometer rotation example ?
I'm playing with the Rotate to Angle behavior but I can't get it work...

Comments

  • FanStudioUKFanStudioUK Member Posts: 459
    Up :D
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    can you be more specific? what exactly do want it do? Tilt the phone and the actor rotates?
  • FanStudioUKFanStudioUK Member Posts: 459
    Yes, when I tilt the phone I want my actor to rotate and move to that direction...but somehow I want to restrict his movement to the Y axis only, so he will move only up and down...
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    So, you are holding the phone in portrait. And when you tilt the phone to the right you want the actor to move up and spin?
  • FanStudioUKFanStudioUK Member Posts: 459
    No, the phone is in landscape mode...
    So, when I rotate the phone, the actor should rotate smoothly to that direction and move up or down on his Y axis.

    Any idea how can I achieve this? I've searched for tutorials but I haven't found nothing helpful.

    Thank you
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    try my "silky smooth tilt demo" on my wall
  • ORBZORBZ Member Posts: 1,304
    be aware that when you flip the device (landscape vs. landscape upside down) that the accelerometer values are not flipped for you automatically and you need to multiply them by -1 to invert them.
  • FanStudioUKFanStudioUK Member Posts: 459
    Thanks for your help guys!

    @scitunes your silky smooth demo is very nice, but I also need my actor to rotate to the position he's heading to... how can I achieve that?
  • FanStudioUKFanStudioUK Member Posts: 459
    Finally I managed to make my actor (drilling machine) rotates when I tilt the device left or right...
    The code I'm using is:

    Constrain - self.Rotatio to vectorToAngle(-game.Accelerometer.Y,-game.Accelerometer.X)-90

    My question is now, how can I restrict my actor to rotate between 2 angles???
    See the picture below...
    image

    LATER EDIT: Problem solved! :)

    What I have to do now is to make the particles rotate after the actor.
Sign In or Register to comment.