W
W
wf_egor2020-09-29 22:28:25
Android
wf_egor, 2020-09-29 22:28:25

How to make a trigger between physical bodies in a unity?

It is necessary that the block writes succes to the console when touching the player. The block has a rigit body, the player has a rigitbody and a box colider. How to do it? I'm using Unity 5. Thanks in advance for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DanielMcRon, 2020-09-30
@DanielMcRon

Put on the player tag "Player".
Throw this code on the box

// Для 2D
void OnCollisionEnter2D(Collision2D collision)
    {
       if (collision.gameObject.CompareTag("Player") )
        {
          Debug.Log("success");
        }
    }

Advice, there is documentation and question tags are not appropriate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question