- Home /
accelerometer Rotation limiting
hey there I am currently working on a game using a accelerometer to rotate a plane . using
transform.Rotate(-Input.acceleration.y * Time.deltaTime * speed, 0, Input.acceleration.x * Time.deltaTime * speed);
but am trying to limit the rotation to like 20, -20 on both x , z axes tried mathf but no luck on getting it to
transform.Rotate(Mathf.Clamp(-Input.acceleration.y * Time.deltaTime * speed,-20,20), 0,Mathf.Clamp(Input.acceleration.x * Time.deltaTime * speed,-20,20));
also tried to use transform.eulerAngles to check for z and x also didnt get it to work since once it goes less then 0 it change to 360
so any idea on how to actually limit the rotation because the plane can be flipped and since i have the camera attached to the plane it wont show but the ball on the plane will automatically fall down .
Answer by CeejayZSmith · Jan 27, 2013 at 06:31 PM
Not tested but i think it should work :)
Input.acceleration.y = Mathf.Clamp(Input.acceleration.y,-20,20);
what angle are you trying to clamp? change the "Input.acceleration.y" to the angle you want to clamp
am only trying to rotate on the x and z axes while locking the Y
Your answer
Follow this Question
Related Questions
limit accelerometer controlled rotation 1 Answer
Android Z Axis 0 Answers
How to limit the rotation of an object?? 2 Answers
Rotation Limit 2 Answers
Make my object's rotation "upright" 1 Answer