I have nested colliders in a GameObject looks exactly like this:
Player (Rigidbody - BoxCollider attached)
- Hand (BoxCollider attached)
Now i put a FMOD Studio Event Emitter to an empty GameObject with a component of BoxCollider.
Its events set to TriggerEnter and TriggerExit.
Now when i go inside that empty GameObject, it triggers as expected but twice.
It seems it plays twice because of unity: https://forum.unity.com/threads/question-about-nested-colliders.590692/#post-3944833
// EventHandler.cs
private void OnTriggerEnter(Collider other)
{
// lets assume that the "other" is GameObject "Hand" and its collider's attachedRigidbody is equals to Player's Rigidbody.
if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag) || (other.attachedRigidbody && other.attachedRigidbody.CompareTag(CollisionTag)))
{
HandleGameEvent(EmitterGameEvent.TriggerEnter);
}
}
private void OnTriggerExit(Collider other)
{
if (string.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag) || (other.attachedRigidbody && other.attachedRigidbody.CompareTag(CollisionTag)))
{
HandleGameEvent(EmitterGameEvent.TriggerExit);
}
}
Should i edit that by my needs? Will it break other things?