I have multiple SphereColliders
attached to GameObject
, one bigger to detect collision danger zone and the other, smaller, for actual collision (both triggers!). When the OnTriggerEnter()
how do I find which one of those two caused trigger enter event?
private void OnTriggerEnter(Collider other)
{
foreach (var collider in GetComponents<SphereCollider>())
{
if(isColliding(collider)) //how to find if this particular trigger isColliding ?
{
if(collider.radius > 0.5)//smaller or bigger one
GetComponent<MeshRenderer>().material.color = _dangerColor;
else handleCollision();
}
}
}
Because the accepted answer provides two solutions, it would be in order to specify how I solved the problem. In the end I went for keeping outter collider and doing "manual" overlap test for inner one (since I did not need physics response, it was the lesser evil). It also turned into new feature, it allows me to lerp danger color.