- Home /
How do I stop a rigidbody from rotating after colliding with another object?
Hi, so in my project I'm working on using grappling hooks to maneuver around trees however whenever my character collides with a tree, it spins out. This causes my camera to not be aligned with the player and my movement gets all messed up.
Below is what I've tried to use to fix the issue however it doesn't seem to work.
void OnCollisionEnter(Collision collider) {
if (collider.gameObject.transform.tag == "Ground") {
Debug.Log("hit ground");
isGrounded = true;
}
if (collider.gameObject.transform.tag == "tree") {
Debug.Log("hit tree");
rigidbody.rotation = Quaternion.identity;
}
}
I was just wondering whether there was any way to stop this rotation on collision.
Thanks :D
Related question: http://answers.unity3d.com/questions/249678/how-to-halt-rotation-after-object-bounce-offs.html
Answer by smoggach · Oct 14, 2014 at 01:50 PM
Hi. SaraCecilia's answer is correct. However if you still want some rotation but not a lot you can modify the rigidbody's Angular Drag. This property dampens the effect the physical world has on the object's rotation.
Your answer
Follow this Question
Related Questions
Plane CollisionWheels keep jumping around 0 Answers
"Freeze Position" applied to an axis affects the bounciness of the object's collider on that axis. 0 Answers
Instantiated objects ignore most of the collisions. -1 Answers
Problem with Rigidbody control script! (collision with perpendicular walls problem) 1 Answer