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 :smiley:

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.