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 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);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us