I have an accelerometer script that works great in portrait mode.
Tilt forward = move forwards Tilt back = move back Tilt left = move left Tilt right = move right
Now I changed things up a bit by forcing player into Landscape mode... I now have the device horizontal with button on right side. This is the mode I want to develop the game for...but the accelerometer script is now confusing me Im not sure how to modify it.
Now I get this from this slightly modified script:
Tilt forwards = move forwards ( ok! ) Tilt back = move backwards ( great! ) Tilt right = goes up?? Tilt left = goes down??
Im not really looking for Y acceleration...I think Im looking for Z rotation?? how do I find this?
How do I get this to:
Tilt right = goes right. Tilt left = goes left.
Well for motion, all you need to do is flip your x and y readings around for the accelerometer when in landscape:
Measuring tilt is a little different however; I use this trig-fu in a Steering Wheel fashion; basically it's like a moving pointer on a protractor and based on the current reading +/- degrees relative to 270. You can do what you want from there (i.e., apply stronger steering force based on whatever Lerp formula you like via that offset). Note, you'll want the code above of course to set the x/y relationship correctly when in landscape.
answered Jun 21 '10 at 05:22 PM