Answer the question
In order to leave comments, you need to log in
How to take into account the collision with the player?
I want it to delete my player only if it collides with the player itself, and ignore the rest of the colliders
private GameObject targett;
void Start()
{
targett = GameObject.FindWithTag("Player");
}
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
Destroy(targett);
}
}
Answer the question
In order to leave comments, you need to log in
You can check the tag...
if (collision.gameObject.CompareTag("Player"))
{
Destroy(collision.gameObject);
}
if (GameObject.ReferenceEquals(collision.gameObject, targett))
{
Destroy(targett);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question