hwo to prevent rotation after hitting an object in unity

Code Example - hwo to prevent rotation after hitting an object in unity

                
                        private void OnCollisionEnter(Collision collision)
{
	GetComponent<RigidBody>().freezeRotation = true;
}