accelerometer ?

Anybody know a good working x axes (right & left) accelerometer tilt?

I'm really bad at this.. for some reason I can't make it realistic

Comments

  • ArmellineArmelline Member, PRO Posts: 5,408

    Google is your friend.

    http://lmgtfy.com/?q=gamesalad+accelerometer+tutorial

    That said, I have never once encountered a game with accelerometer controls that I didn't hate.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited January 2015

    Hi @http_gamesalad, I have an Accelerometer Tutorial you might find useful. There are several methods of setting up controls, but the one below worked well for the game I was developing at the time.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @jamie_c‌ thanks :)

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    You're welcome, hope it helps.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @jamie_c hey I tried out your video & its working, kinda sorta.. when I tilt right it works but when I tilt left nothing happens... I double checked everything... Are you sure its accelerometer.x > -0.005? & not (<) instead? Thanks :)

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    I haven't watched that video but the general idea is that accelerometer values are neutral at 0 and then small tilt motions cause the attributes to become either positive or negative depending on the direction. So you'd either be checking for > [small positive number] or < [small negative number]. If you instead do >0 and <0, you end up with no way to stop the motion (it's basically impossible to get 0 by holding the device really still, but it's not so difficult to get something like 0.1 or -0.1). The use of X, Y, or Z depends on the physical orientation of the device. I usually place a Display Text behavior in an actor to show all three values and use roundTo(attribute,numberOfDecimalPlaces) to shorten the displayed value. Then when I move the mobile device, I can see the values and how they change.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited January 2015

    @http_gamesalad, yeah I'm sure that is how it was set up and working. See @tatiang explanation of why above. If it's helpful to you I have the source files available for free for all my tutorials at my website (linked in my signature below). Feel free to download the file and rip it apart to see just how it works, I'm sure you'd find any errors in your behaviors that way.

    The demo file does exactly what is mentioned above, there are two text display actors on screen so you can see exactly what numbers are registering on the device, you can see them in the video when I demo it on an actual iPad.

  • LovejoyLovejoy Member Posts: 2,078

    @http_gamesalad said:
    jamie_c hey I tried out your video & its working, kinda sorta.. when I tilt right it works but when I tilt left nothing happens... I double checked everything... Are you sure its accelerometer.x > -0.005? & not (<) instead? Thanks :)

    Test it out and mess around with the values a little bit. If i remember correctly, this template needed a little tweaking last time i messed with it.

Sign In or Register to comment.