Need math help - tilt calibration

scitunesscitunes Member, Sous Chef Posts: 4,047
edited November -1 in Working with GS (Mac)
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!

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    any math geeks out there?

    :)
  • JackBQuickJackBQuick Member Posts: 524
    I'm not good at math but I did a Google search and came up with this:

    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 :)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    way over my head! thanks though
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    I probably don't understand what your asking :) but I made this custom calibration tutorial back in december to allow you to set a custom angle of play. maybe it'll help?
    http://gamesalad.com/game/play/30319
  • jon2sjon2s Member Posts: 40
    I believe that the problem that both scitunes and myself are having is that the gravity or simulated gravity is constrained to the value of the accelerometer. This works just fine and you can even calibrate it, but the problem comes in if you want to say calibrate it with the iphone/pod/pad in a vertical position rather than horizontal like on a table is that the calibration gets off because once of how the accelometer works.

    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.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    @jon - you bring up a good point, but that is not my exact issue.

    @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!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I am hoping codemonkey or FMG will have an idea. Until then I will see if a math teacher I work with can help.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hopefully CodeMonkey, ORBZ, or rebump will chime in and be able to help you.

    I haven't worked with the accelerometers at all yet...plus I'm not really that good at math! (I'm better at logic)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Thanks, Joe.

    I know you say you're not good at math, but what is math if not logic? :)
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Maybe I'm not that good at logic after all... :0)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I was actually suggesting the exact opposite!

    :)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Got it

    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 :)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    weird. The "New PRoBLEM" I described above was only a problem on my iTouch, but works perfectly on my iPad. So for now problem solved.
Sign In or Register to comment.