How to add rigidbody with script?

I have a cube in the game that when the player collides with it, it should b added a rigidbody to fall down. This is the script that the player has:

function OnCollisionEnter (other : Collision) {
	if(other.gameObject.tag == "WoodTag")
		var rb : Rigidbody = other.gameObject.AddComponent(Rigidbody);
		rb.mass = .5;
		rb.drag = 2.0;


the problem is that nothing happens! why?

lol I was bugging my head why does not work for me too

OFC it does not work

IT must have a rigidbody to add it

untill you won’t have rigidbody inside your script wont activate it self


  • box 1 (script + rigidbody)
  • box 2 (nothing)

moving box 1 in to box 2 returnes me debug only 1 that I’m in function not more than 1 time no matter how much I try

moving box 2 in to box 1 does not return me debug

if I give rigidbody to both I get debug both times but only for 1 colision don’t know why but still answer is add rigidbody

Above is for OnColision

Bottom is for OnTriggerEnter

the Cube has to have this script AND RigidBody

void OnTriggerEnter (Collider Other){
	Debug.Log("In Collider Works");
	if (Other.tag == "Player"){
		gameObject.rigidbody.useGravity = true ;
		gameObject.collider.isTrigger = false ;
		gameObject.rigidbody.AddForce(new Vector3(0,-1,0));