OnTriggerEnter - Objects pass through each other?

I have 6 primitive cubes stretched out to form the “walls” of a large box. Inside the box, I spawn some number of primitive spheres with random velocities.

I have colliders on the cubes (“walls”) and on the spheres.

I have rigidbodies on the spheres but not the cubes.

When I press PLAY, everything works fine. The balls spawn and go bouncing happily about the inside of the box.

But, if I set the tick mark for “Is Trigger” on the spheres, all my spheres go sailing right through the walls of my box. Nothing is being destroyed… except the physics of the collision itself.

I’m not sure what is causing this or how to prevent it.

Just to be clear - setting isTrigger means that you do not want the collisions to happen in the physics system - you just want to be notified.

Triggers are used to provide a way of activating something when the character is in a particular location by using colliders but without those colliders having a physical impact.

I presume that you want to be notified about the collisions and have them provide a physical impact - in this case you need to use OnCollisionEnter routines (not the Trigger ones).

I hope I got u right^^ Make 2 different colliders. For example 1 sphere collider and a box collider which you set as Triger. As soon as it is a trigger, it ignores collisions between other gameobjects so you need a constant collider.

If I follow Maru07’s suggestion, I get the behavior I want. I have to create an empty gameobject, give it a collider and rigidbody, then make my sphere/ball a child of this gameobject.

It works, but it’s not exactly an elegant solution.

Thanks Maru07.