- Home /
c# problem with limiting rotation (with rigidbody)
So i have a hover car , i have a box collider , a rigidbody attached to it and a script that controls the hovering physics . I want to prevent the car from flipping over by limiting its rotation on the x and z axis (left y out to allow it to turn) i used the following line of code to clamp its rotation but the rotation seems to be completely frozen . Here's the code i used : "transform.rotation = Quaternion.Euler(new Vector3 (transform.rotation.x,transform.rotation.y,transform.rotation.z));"
You can set the values max and $$anonymous$$ for the rotation
Answer by kevinspawner · Dec 24, 2014 at 08:52 AM
You need to use clamp min and max values and then once it reached the clamping values you need to pass the new rotation back again to the rotation value.
Your answer
Follow this Question
Related Questions
How do I limit the vertical rotation of a camera? 0 Answers
Clamp rotation of a GameObject 1 Answer
Aligning player to surface 2 Answers
Preventing rotation of rigidbody at a specific rotation 0 Answers
Limit distance from center 0 Answers