Destroying the floor

I’m trying to destroy the floor when lerpz walks onto it. The floor is named WeakFloor but I don’t think lerpz is picking up the collision.

function OnCollisionStart(hit : Collision){

if(hit.gameObject.name == "WeakFloor"){	
	Destroy(gameObject.Find("WeakFloor"),3);
}

}

Three simple lines any ideas why that doesn’t work

It’s a really simple mistake (I think). Try this

function OnCollisionStart(hit : Collision)
{    
  if(hit.gameObject.name == "WeakFloor"){ 
    Destroy(GameObject.Find("WeakFloor"),3);
  }    
}

The change is ‘gameObject’ to ‘GameObject’ (capital G). ‘gameObject’ is referring to Lerpz and his hiarchy, whereas ‘GameObject’ will refer to the whole scene.

thats not it. The problem is in the if statement because if I run this code below

function Start () {
Destroy(gameObject.Find(“WeakFloor”),10);
}

That works no problem at the start. Thats why i know the problem is in the collider.

Now I want it to happen when Lerpz walks on the “weakfloor”

I figured it out. Since it is a character controller I had to use

function OnControllerColliderHit(hit : ControllerColliderHit)

instead of

function OnCollisionStart(hit : Collision)

I had to do this because lerpz is a CharacterController