Reputation: 2953
I have a hirarchy like so:
in the parent i have a the following components:
the child called DropDetector
has a collider marked as a trigger. and the child called drop_area
also has a collider but this one IS NOT marked as a trigger. But at the moment my OntriggerEnter and Exit functions are being called from the drop_area
collider eventhough it is NOT marked as a trigger. Why is this happening? And how do i stop it from happening?
The DropArea
script and rigidbody are attached to the parent called IncrementA_DropArea
If anymore information or clarification is needed pls let me know so i can clarify!
Upvotes: 1
Views: 1327
Reputation: 20269
This is working as intended. From the unity docs on MonoBehaviour.OnTriggerExit(Collider)
:
This message is sent to the trigger and the collider that touches the trigger.
You can not avoid this from being called on drop_area
's MonoBehaviour
s.
However, in the implementation of MonoBehaviour.OnTriggerExit(Collider)
, you can check first if the called MonoBehaviour
's collider is not a trigger, and exit the method if so:
public Collider myCollider;
...
myCollider = GetComponent<Collider>();
...
void OnTriggerExit(Collider other)
{
if (!myCollider.isTrigger)
{
return;
}
// Do stuff for trigger here.
}
Upvotes: 3