playMaker

Author Topic: [SOLVED] Invert Accelerometer  (Read 2675 times)

Horror

  • Junior Playmaker
  • **
  • Posts: 79
[SOLVED] Invert Accelerometer
« on: June 06, 2012, 05:57:27 AM »
Hey!

I'm trying to apply what I learned in the Acceleration video tutorial to a camera view so I can look around using the accelerometer on my device. Tilt to the left should rotate the object clockwise, right for anti-clockwise.

This works fine for rotating an object that you are looking at, but if you are the object being rotated then tilting to the left will make you look right and vise versa.

I'm guessing I have to convert the Y float variable from the device to a negative equivalent and update it every frame? I've tried creating an additional variable, setting its Y value to the value of the global variable taken from the device and then using an Abs to convert it every frame. That didn't work, though... the result is probably being stomped every time the device updates.

Any ideas as to how I should go about this? I know I'm going to punch myself when I hear the answer!
« Last Edit: June 06, 2012, 10:26:40 AM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Invert Accelerometer
« Reply #1 on: June 06, 2012, 06:15:01 AM »
Hi,

 It's hard to tell like this, but yes, you should get the acceleration value and the next action must be a float multiply that multiply by -1.

 if that's not the case, then it might simply be a problem of rig set up and transform.

 I suggest the following. take control of the value yourself without the accelerometer, and see how the cube is behaving. if it behaves find, either you are mis interpreting the accelerometer value or something is odd in the process. you can do that with a joystick for example, or simply with the keyboard.

Also, do you have some debug tools to watch the values of the accelerometer, so that you are actually sure about the outputs, this does help a lot as well.

Bye,

 Jean

Horror

  • Junior Playmaker
  • **
  • Posts: 79
Re: Invert Accelerometer
« Reply #2 on: June 06, 2012, 06:57:29 AM »
Awesome! That did the job.

Thanks Jean!