- Home /
Rotating Object w/ iPhone Accelerometer
I ran into yet another problem in my game. Basically, you are rotating an object around its y axis by tilting the accelerometer. The problem is, when the object has rotated to within a few decimals of 180, it stops rotating. Here's the code that I am using:
transform.rotation.y-=Input.acceleration.y *0.05;
I tried something like the following, but it errors saying that I cannot use a type float.
transform.Rotate(Input.acceleration.y *100.0);
All I want the object to be able to do is rotate all the way around as many times as the player wishes. I know that this is very basic stuff, but I just cannot figure it out.
Thanks in advance!
-Robert
Answer by AppTechStudios · Feb 19, 2011 at 10:01 PM
This code works:
iphoney=-Input.acceleration.y;
transform.Rotate(Vector3.up*iphoney*5.0);
Great!!! I love you :) It works Thank you
function Update () { var iphoney=-Input.acceleration.y;
transform.Rotate(Vector3.up*iphoney*5.0); }