Search Unity

Problem with coliders not registering.

Discussion in 'Scripting' started by VRaptorX, Sep 12, 2012.

  1. VRaptorX

    VRaptorX

    Joined:
    Sep 27, 2011
    Posts:
    108
    PHP:
    function OnCollisionEnter (col Collision){
        
    //if(col.gameObject.tag == "Blade"){
            
    Destroy(this);
        
    //}
        
    }
    This should be so easy. If you touch ANYTHING, destroy yourself.

    It collides with things. It flat out stops in it's tracks. I can pick it up and move it around. But it never destroys.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    If you say
    Code (csharp):
    1. Destroy(this);
    ...it will only destroy the script component on the object. To destroy the object itself, you need:-
    Code (csharp):
    1. Destroy(gameObject);