unity disable rigidbody collision code example

Example 1: how to disable and enable rigidbody unity

// if you want to disable the rigidbody on which the script is sitting on
// you can't do that but you can go around it by 

// Just destroying the rigidbody by calling
Destroy(gameObject.GetComponent<Rigidbody>());

// and if you want it again call
gameObject.AddComponent<Rigidbody>();

// Remember "gameObject" with small 'g' reffers to the gameObj on which the script
// is sitting on

// -*-*-*-*-*-***-HAPPY CODING-***-*-*-*-*-*-

Example 2: unity rigidbody2d disable

//you can't :(
//you can delete it with
Destroy(RigidBody2D);