Accelerometer Movement Done Right

2»

Comments

  • BluemoonstudiosBluemoonstudios Member Posts: 156
    nice plug @joeMeister =;
  • Agent ArgyleAgent Argyle Member, PRO Posts: 188

    @ericzingeler said:
    themagicbox
    Bluemoonstudios

    Here's an updated project file with up,dn,left,right tilt. Turns out we needed to use accelerometer Z (roll), not x. Also, to move along x-axis, we use accelerometer Y; so I apologize for the wrong instruction before.

    https://dl.dropboxusercontent.com/u/27937751/gs/modules/AccelerometerFilter_v1.0_05_23_13.gameproj.zip

    2 years later and this is still helpful. thanks! I know it has been a while, but can you explain why you use accelerometer.Z instead of X? Also, why do you set the center point in the demo provided? Thanks!

  • ant_ladant_lad Member Posts: 222

    This might help explain it for you. It is for windows but is really for any accelerometer. 'Z always starts by pointing down'. http://tutorial.programming4.us/windows_phone/sensors-and-services---accelerometer.aspx

  • Agent ArgyleAgent Argyle Member, PRO Posts: 188
    edited January 2016

    From @ericzingeler

    I've got this method working pretty well in my game Airlift but someone recently pointed out that if you tilt the device too far up then you go down instead of up. I noticed this happens in the demo as well.

    I assume this happens because the orientation flips, But it happens even if you lock the orientation of the screen by only checking landscape right when publishing. I tried unchecking all of the auto-rotates in the scene attributes but that didn't have any effect.

    Perhaps it has something to do with the Z axis instead?

  • iansmaleiansmale Member, PRO Posts: 1

    Hi @ericzingeler

    I know this thread is pretty old, but I only just signed up with GS and came across it now. This stuff is awesome! I was wondering if you could post the project file with up, down, left, right movement again? The Dropbox links in the thread are no longer working. Thanks so much in advance!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Here is the whole of the technique:

    Change Attribute: self.tiltOutput To: 0  
    Change Attribute: self.tiltFlip To: 1  
    Change Attribute: tiltSpeed To: 1600  
    Constrain Attribute: self.tiltOutput To: (game.Accelerometer.Y*.04)+(self.tiltOutput*.96)  
    Move:  
       Direction: 0 Speed: self.tiltOutput*self.tiltFlip*self.tiltSpeed  
    When: game.Screen.Interface Orientation is: Landscape Left  
          Change Attribute: self.tiltFlip To: -1  
       otherwise  
          Change Attribute: self.tiltFlip To: 1  
    
  • JapsterJapster Member Posts: 672

    @ericzingeler , @RThurman - Thanks Eric, for the code, and the kindness of RThurman in making it available after the Dropbox links died - owe you guys big time!!! :smiley:

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    No problem! Glad its going to help.

  • PhilipCCPhilipCC Encounter Bay, South AustraliaMember Posts: 1,390

    @RThurman Thanks for the whole technique. This is really cool.

    @iansmale I have been around since 2012 but only just found this thread. Thanks for asking about it and reincarnating it. :)

    I just love it when we uncover little gems like this in GS.

Sign In or Register to comment.