Accelerometer Question

JamesBoucherJamesBoucher Member Posts: 433
edited November -1 in Working with GS (Mac)
I'm creating a racing game and need some help on using the accelerometer. I know how to use the accelerometer if the object has no front (like a ball). I need to find out how to use accelerometer with a car.

Comments

  • JamesBoucherJamesBoucher Member Posts: 433
    Any help would be great. Thanks, Thanks and Thanks.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    my first thought would be to have an invisible actor.

    This invisible actor would simply be a square, and this is what you actually control with the accelerometers. This square would not rotate. It would just slide around the screen.

    The car sprite would have it's rotation constrained to the position of the invisible actor,
    using vectorToAngle(invisibleX-carX,invisibleY-carY)

    But i'm just thinkng off the top of my head
  • VmlwebVmlweb Member Posts: 427
    You can use my app GameSalad Devices to view the co-ordinates
    more info at http://vmlweb.co.uk/page.php?15
  • JamesBoucherJamesBoucher Member Posts: 433
    Thanks for the help...
  • JamesBoucherJamesBoucher Member Posts: 433
    I tried having the car follow the invisible actor but it real jerky on the Mac. On the iPod it just can't keep up. I have no problem controlling the invisible actor using accelerometer. The problem is controlling the actor that has a front to it.

    Any other suggestions?
  • JamesBoucherJamesBoucher Member Posts: 433
    Any suggestion from someone at GS?
  • JamesBoucherJamesBoucher Member Posts: 433
    I'm going to put this game on hold until I can find an answer.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Can you just use the accelerometer.Y < / > rules as shown in the wiki and use the rotation behavior instead of a move behavior? Then have a button that controls forward acceleration (your gas pedal) and another that acts as the brake. You could market it as having "tilt steering" and touch controls.
  • JamesBoucherJamesBoucher Member Posts: 433
    Thanks scitunes for the suggestion. I will give it a try.
  • expired_012expired_012 Member Posts: 1,802
    Sorry im posting on something from so far back but i didnt want to start a new post.

    My brain is not really working properly today and i sort of forgot about acceleration so i have a quick question

    Say I have an actor in portrait mode, and I want it to move left and right using the accelerometer. How can that be done? The less then 0.1 and -0.1 and greater than things confuses me. if anyone knows please help
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    go to iTunes and download iDevices. it is a simple free GS made app that shows you a number of things including the X, Y, and Z data while tilting. The basic idea is that if you are holding the phone as a phone then X and Y are just like in math class. X - side to side, Y - up and down. But most iphone games tip the phone landscape but the X and Y do not change so in landscape X becomes the vertical and Y becomes the horizontal. Basically as you tip your phone to the right the Y value changes between 0 and 1 (or negative 1 depending on which landscape you are using - this is where iDevices is really handy). Tipping it to the right changes the value to something between 0 and -1.

    Use these values with the > or < to set up your rules. I started out by just copying other peoples rules from demos and forum suggestions, but I highly recommend using iDevices to figure it out for yourself as it will make you a better programer.
Sign In or Register to comment.