Need math help - tilt calibration
scitunes
Member, Sous Chef Posts: 4,047
I know how to calibrate the tilt to a custom angle when using accelerate based on the accelerometer data, but I am using constrains not accelerate so I need some help.
Here's what I have:
constrain self.positionX to self.Position.X -( game.Accelerometer.Y *14)
constrain self.positionY to self.Position.Y +( game.Accelerometer.X *14)
The controls feel EXACTLY like tilt to live so I do not want to that to change. But currently it only works if you are holding the iPad completely level. I was hoping to have a real attribute called "calibrateY" and have the player hold the device at the desired angle tap a button and it changes game.calibrateY to game.accelerometerX.
BUT...
I can't figure out what to do with the game.calibrateY attribute. How do I work it into the equations above to allow a custom tilt?
Thanks!
Here's what I have:
constrain self.positionX to self.Position.X -( game.Accelerometer.Y *14)
constrain self.positionY to self.Position.Y +( game.Accelerometer.X *14)
The controls feel EXACTLY like tilt to live so I do not want to that to change. But currently it only works if you are holding the iPad completely level. I was hoping to have a real attribute called "calibrateY" and have the player hold the device at the desired angle tap a button and it changes game.calibrateY to game.accelerometerX.
BUT...
I can't figure out what to do with the game.calibrateY attribute. How do I work it into the equations above to allow a custom tilt?
Thanks!
Comments
3D Tilt calibration
Is this what you are after? Honestly, the math is so beyond me that I'm not even sure that there's an answer in there
http://gamesalad.com/game/play/30319
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
When the device is lying flat on a table, the x and y accel. values are 0. Once put it vertical, the x or the y is 1 (depending on which side is up). Now comes the hard part. If you tilt the device 10 degrees forward the accel. value goes from 1 to .9. If you tilt the device backwards 10 degrees, the accel. value is still .9. So creating an offset to calibrate it the way that my mind works, simple doesn't work.
I'd love to see if anyone has any ideas, but I'm fresh out.
@mulcahy - I have used you demo before and it works great as a calibration method for the movement rules you use. The problem is that your method requires the use of an accelerate or move behavior - which I have found to be impossible to get to feel right. If you use the constrain method I describe above, the feel is almost exactly that of tilt to live. So I really want to stick with that method, I just don't know how to modify it so it works at an angle other than completely flat.
I would be happy if someone could direct me to giving the player the option of flat or 60 degrees. Obviously giving the player the ability to completely customize the angle is ideal.
Thanks!
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
I haven't worked with the accelerometers at all yet...plus I'm not really that good at math! (I'm better at logic)
I know you say you're not good at math, but what is math if not logic?
You just need to add the calibrate value. For example if you want 45 degrees that is an X value of -.5 so you add .5 to the x value so that 45 degrees acts like the new zero.
so constrain self.positionY to self.Position.Y +( game.Accelerometer.X *14) becomes:
constrain self.positionY to self.Position.Y +( (game.Accelerometer.X+.5) *14) to play at a 45 degree angle.
NEW PROBLEM:
It screws up my vector to angle to get my actor to always point forward. I tried changing game.Accelerometer.X to (game.Accelerometer.X+.5) within the VectorToAngle.
Now Joe, I know you know a thing or two about vector to angle