Answer the question
In order to leave comments, you need to log in
How to find out who called OnTriggerEnter2D?
I have a parent object and 3 attached to it (1 pair and a second object) with triggers and only 1 script that is attached to the parent, how to find out which of the 3 child objects called it with OnTriggerEnter2D?
Answer the question
In order to leave comments, you need to log in
You hang these lines of code on the object with which the objects you need will collide, after which you will get access to the object that collided with the object on which the script
public void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log(collision.gameObject.name);
if(collision.gameObject.name == "Имя того кого ищешь")
{
Действия
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question