U
U
Uncle Bogdan2021-08-16 14:08:15
Unity
Uncle Bogdan, 2021-08-16 14:08:15

Why doesn't OnTriggerEnter2D fire?

Like code:

public void OnTriggerEnter(Collider other)
    {
        print("BOOM");
        Destroy(gameObject);
    }


And objects:

Wall:

https://b.radikal.ru/b25/2108/b2/1a600f290534.png

And bullet:

https://a.radikal.ru/a38/2108/4c/7580ce353687.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SwathingSoap, 2021-08-17
@motkot

You use the OnTriggerEnter function, which works with 3d objects/colliders, when you use 2D colliders in the scene, for which you need to use the function: https://docs.unity3d.com/ScriptReference/MonoBehav...

N
Nekit Medvedev, 2021-08-17
@NIKROTOS

try creating a trigger for the object being destroyed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question