- Home /
Tilt object acceloremeter limited
Hi all,
I hope someone can help me out with this. In a simple game i am making i want to tilt an object on the horizontal axe.
The problem is i only want to tilt it a little to both sides and then stop tilting. So the tilting should be limited.
var rollSpeed = 5.0;
var rollAmount = 0.0;
var currentangle = Input.acceleration.x;
function Update() {
if (Input.acceleration.x <90 ) {
rollAmount += rollSpeed ;
} else if (Input.acceleration.x <90) {
rollAmount -= rollSpeed ;
}
transform.Rotate(0, 0, rollAmount*Time.deltaTime);
}
This is the code i am working on right now. I don't know how to write the code this way that it will do what i want. The result i have now is that the object keeps turning...
Your answer
Follow this Question
Related Questions
I want to rotate an object by the Y axis using the phones accelerometer 0 Answers
Smooth Accelerometer tilt rotation 0 Answers
Smooth rotation from accelerometer 0 Answers
Android Z Axis 0 Answers