Determine which collider collided

I have a game object with two spherical colliders attached. One of them is tested by Isrrigger, and the other is not.

I want to execute different commands when a collision occurs with different colliders. For example, I want to play a different sound for both different collisions. Is there any way to achieve this?

I tried OnTriggerEnter (), but unfortunately it is called for both types of collisions, as other colliding objects trigger colliders. I just thought that if we could somehow figure out which collider of the game object had a collision, we could reach it.

So can this be dealt with?

+4
source share
1 answer

Unity , . , Unity .

Physics.OverlapSphere Physics.CheckSphere , -, . , , OnTriggerEnter. , , .

+1

Source: https://habr.com/ru/post/1584973/


All Articles