D
D
Default_Nickname2022-02-20 21:22:59
Unity
Default_Nickname, 2022-02-20 21:22:59

How to make it so that when an object with a specific tag touches another object (also with a specific tag), [something] happens?

Let's say if (object with tag "1") touches (object with tag "2"), then something happens, for example, a message is printed to the console.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LittleBob, 2022-02-20
@Default_Nickname

Add Collider and Rigidbody to both objects. Create the necessary tags for both objects.
And for example, in the script of the first object, write this:

void OnCollisionEnter(collision col)
{
if(collision.gameObject.tag == "тэг второго объекта")
{
Debug.Log("первый объект столкнулся со вторым")
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question