Answers for "unity destroy object on hit"

C#
5

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);     
   }
}
Posted by: Guest on March-06-2021

C# Answers by Framework

Browse Popular Code Answers by Language