- Home /
ow can I limit rotating an object that uses the device's rotation?
I would like to know how to limit the rotation of a device when it reaches 45 degrees z and x. When I tilt the device, tilts the object too, but it doesnt stop tilting. Anyone know how to limit it? Since already thank you. Here's my script.
public Vector3 rotateDir = Vector3.zero;
public float rotateSpeed = 3.0F;
// Update is called once per frame
void Update() {
rotateDir.x = -Input.acceleration.y;
rotateDir.z = Input.acceleration.x;
if (rotateDir.sqrMagnitude > 0.3)
rotateDir.Normalize();
transform.Rotate(rotateDir * rotateSpeed);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220611225909im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Minecraft Biomes: How to Make? 2 Answers
How do i divide int by float? 1 Answer
Why can't I divide this number by 100? 1 Answer
Triangle and vertex count after dividing them n times. 0 Answers