Horje
Unity Destroy gameObject upon collision Code Example
unity destroy object on collision
void OnCollisionEnter2D(Collision2D coll)
}
   // Check if we have collided with the enemy
   if (coll.gameObject.tag == "Enemy")
   {
      Destroy(coll.gameObject);     
   }
}
Unity Destroy gameObject upon collision
void OnCollisionEnter2D(Collision2D collision)
{
    Destroy(gameOnject);
}

// Or if you only want it to be destroyed when 
// hitting something specific

void OnCollisionEnter2D(Collision2D collision)
{
    if(collision.gameObject.tag == "tag")
    {
         Destroy(gameObject);
    }
}




Csharp

Related
c# check if array contains value Code Example c# check if array contains value Code Example
csharp csvhelper Code Example csharp csvhelper Code Example
change size of a unity object Code Example change size of a unity object Code Example
how to use navmeshagent in unity Code Example how to use navmeshagent in unity Code Example
unity get perlin noise 3d Code Example unity get perlin noise 3d Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10