Accelerometer suggestions needed
tsextro
Member Posts: 25
I am creating a game which will do different things depending on the accelerometer at different times. My goal is to determine when someone moves the ipod touch too much in the x, y, or z direction. (The player has to hold still at different times of the game.) My thought is that there would be a variable that would put the accelerometer x into a variable x and the same for y and z. It would constantly check to see the difference between what was what was in x originally and the current accelerometer setting an if it deviated more than 0.2 or some number, the game would be over. Other times during the game, it doesn't matter how much movement in the x, y, or z direction there is on the ipod touch. I know there are times when the difference could be either positive or negative and I'm not sure how to calculate absolute value. Any guidance in this area would be appreciated.
Comments
Took x value and deducted 0.2 at the start, saved the value into an attribute called x1. Change attribute x2 to the value of x. Then just a rule for when x1 is less than x2 then trigger event.
Think your'd have to set a few more crude attributes and rules to get it to work to 'check for hold still' mine was checking for a movement. As said hopefully someone with a little more brain power will know how to work out the difference between two attributes
rule that says if ANY
game.accelerometerY > .1
game.accelerometerY < -.1
game.accelerometerX >.1
game.accelerometerX < -.1
-------Insert Game Over Sequence Here
You can change the .1s to a higher decimal to be more forgiving or a lesser decimal value to be less forgiving.