Accelerometer movement

FanStudioUKFanStudioUK Member Posts: 459
edited November -1 in Working with GS (Mac)
I want to use in my game the accelerometer movement.
I want to know who tested it and if it's running smooth.
I have the iPhone in landscape mode and I need my player to move left or right depending on how you tilt the device.

Any help would be appreciated.

Thank you!

Comments

  • FanStudioUKFanStudioUK Member Posts: 459
    Got it, Scitunes idea is great, working like a charm!

    Constrain attribute: self.Position.X To: self.Position.X + (15*game.Accelerometer.Y)
  • CaptainChocoCaptainChoco Member, BASIC Posts: 124
    Thanks, Andrei.
    That's what I was looking for!
  • FanStudioUKFanStudioUK Member Posts: 459
    Ahoy Captain!

    Dead men tell no tales, right?

    Cheers mate!
  • ORBZORBZ Member Posts: 1,304
    That's going to be glitchy.

    You should avoid constrainig attributes to themselves.

    Better:
    Constrain linearVelocityX to accelerometer*100
  • FanStudioUKFanStudioUK Member Posts: 459
    Thank you Orbz! :) I should try that!

    Please reply to my email when you'll have time ;)
  • ORBZORBZ Member Posts: 1,304
    What email? Did you send me an email?
  • FanStudioUKFanStudioUK Member Posts: 459
    Yes, last night...I will send it again now :)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    the above formula isn't glitchy at all for me. That being said, I would trust Orbz when it comes to coding. Last time I tried to challenge him it wasn't pretty!
  • ORBZORBZ Member Posts: 1,304
    @ scitunes

    Hehe...

    The glitchyness I'm talking about is something gendai specifically warned us about back in 0.8.x. Whenever we constrain a variable to itself we are, in effect, tying the performance of that variable to the speed of the cpu (the fps). That means that on faster hardware the x slider in your example will tilt faster and on slower hardware it will tilt slower. This is what's called cpu-bound. To prevent this we need to make the simulation time-bound, that is, that time is non-varying (well at least on earth) and so we can use it as a constant to which everything else is measured.

    LinearVelocity is a measure of distance over TIME. (An easy way to remember that velocity is a measure of distance over time is Miles PER Hour = mph = miles/hour = distance/time) So long as we have time buried in our equation somewhere, then motion becomes fluid and it doesn't matter how fast or slow the cpu is it will always move the same distance over the same period of time. Simply setting the linearVelocity parameter tells the physics engine to compute distance over time.

    In the prior method of constraining x position to itself we are saying to move the position of x every cpu tick, which may or may not look good on different hardware.

    The reason you can't see a difference right now is because GameSalad is so damn slow. But if / when GameSalad has major performance improvements self constraining attributes will cause weird timing glitches. Things that were moving at a good speed before will suddenly zip around waaaay to fast.

    Ahh... math before breakfast... yum. :)
  • ValanValan Member, BASIC Posts: 410
    Thanks Orbz.

    I used your suggestion and it works like a charm. Made things much better.

    Cheers
Sign In or Register to comment.