Hi - I’m trying to rotate an object based on an iphone’s tilt in the x direction. I’ve got a kind of janky formula that calculates rotation amount (rotAmt) to have a min of -5 degrees, max of 5 degrees, or anything in between. But when I call the function that monitors the tilt of the device (monitorTilt), it seems to rotate the item relative to its previous position and not to the world space (or to its starting rotation of 0).
Here’s my code:
var dir : Vector3 = Vector3.zero;
dir.x = Input.acceleration.x;
rotAmt = -((dir.x*100)/2)/5; //get the degrees we will rotate the lighter around the y axis (in degrees);
Debug.Log(rotVal);
flamePlane.transform.Rotate(0,0,rotVal,Space.World);
What do I need to do to fix this?