Accelerometer Input Rotation Help
I'm making a mobile shooting gallery style game, where you use the accelerometer to aim the camera. Currently, the game works when the device is being held pointed down, instead of forward like you would hold it normally. I would like it to work when you are holding the device in this way. I've spent a couple of days now trying to figure this out, but after failing several times, I decided it was time to consult the forums.
Here's the code:
a.SetFloat("Horizontal", -Input.acceleration.x);
a.SetFloat("Vertical", -Input.acceleration.y);
in the animator, I have a blend tree to blend between the cannon pointing up, down, left, and right. Originally, this was because I had buttons to move the cannon and I wanted to limit the rotation, however now I still have it because it's the only way it seems to slightly work.
Also,
a.SetFloat("Horizontal", Input.acceleration.x);
a.SetFloat("Vertical", Input.acceleration.z);
works in terms of keeping the device pointed forward, however, looking left and right only changes when tilting the device, instead of turning it left/right.
So the question is, how do I make an object rotate according to the accelerometer?
Any help is greatly appreciated. Thanks!
provide your code & more info : portrait or landscape & i can't differentiate between pointed down & forward
Landscape. And by pointing down, I mean holding your device so that the back of the device points to the ground, and forward is where the back of the device points forward, as if you were taking a picture. Code has been added.
this is the animator code but cheek this short tutorial from unity with one line of code Accelerometer Input
Your answer
Follow this Question
Related Questions
Problem with Android platform 0 Answers
Is it possible to access the native step-counter on mobile platforms. 2 Answers
Mobile bloom kills performance 1 Answer
Limit Z axis rotation on main camera (BUG?) 0 Answers
How do I pause the accelerometer? 1 Answer