is sphere trigger have bug?

hi.

in my game, i have two objects.

first object have 2 box collider. one of which have " is trigger " option “ON” and another doesnt(for rigidbody collision) and a script with have a “OntriggerEnter” function.

The second object have a sphere collider and also with " is trigger " " on ".

the problem is when first object collides to second object, the " OntriggerEnter " function runs 2 times!!!

and that because of the box collider which that " is trigger " option Off!!!

i remove the second object " sphere collider " and replace it with a box collider and that works just fine.

i dont know this is a bug in unity or I am making a mistake.

thanks. glad to see your answers.

Hello.

Ontrigger functions are called every time any kind of collider enters the trigger collider of the obejct that contains the function.

So you Ontrigger function is detecting the 2 others object colliders, the triggger and the non-trigger.

To prevent this things, you can have the colliders in different object, i mean, The Object A has no colliders, but have 2 children, each children have 1 collider each, one trigger, one non-trigger, so now, any other object can see wich of the colliders is triggering it.

Another option is to have one of the colliders in the main object, and the other in a child object.

As you can set the layer of each object, you can use the Collision matrix to decide the collliders of what layers, collide with which other layer.

Good luck!