Accelerometer

liamoliamo Member Posts: 191
edited November -1 in Working with GS (Mac)
hello. I'm trying to make a platformer and i want my character to move left when the iphone is tilted left and vice versa, how do you do it?

Comments

  • cogwerx.llccogwerx.llc Member Posts: 4
    Why is this a poll?
  • liamoliamo Member Posts: 191
    The poll button is just so easy to press!
    can I have an answer please :)
  • dotsonj23dotsonj23 Member Posts: 316
    Rule within actor you are moving: When All --> accelleramator Y is less than or equal to -.2
    Place within rule accellerate behavior and have it accellerate relative to scene, direction 0 (for right movement), and put in speed at which you want it to accellerate.

    That will get you movement to the right. Movement to the left would be the same rule but instead direction should be 180 and the -.2 should be just positive .2. If you want it to stop when not tilting add another rule when accelleramator Y > -.2 and when accelleramator Y is < .2, interopolate (or change attribute depending on how fast you want it to stop) self.Motion.Linear Velocity X = 0.

    That works in my game.
  • liamoliamo Member Posts: 191
    Thanks, that works the trick, how do you test it on the preview player though?
  • dotsonj23dotsonj23 Member Posts: 316
    You have to test it with GS Viewer on a device. You can download the GS Viewer to your Mac. Then you need to build it in X-Code onto your device. TShirtbooth has a video on how to do that at GSHelper.com. Wow, I am really pushing his site tonight. But he and the site are great. Anyway, this all assumes you are a registered Apple Developer (costs $99 for individual for a year). If you are not, you cannot test it on your device.
Sign In or Register to comment.