- Home /
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.
Have you tried giving the boxes rigidbody, just for testing.
Thanks Linus, but adding a rigid body to the "walls" (cubes) has no effect. :(
Answer by whydoidoit · Jul 04, 2012 at 03:50 AM
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).
Answer by Maru07 · Jul 04, 2012 at 12:16 AM
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.
Answer by rule62 · Jul 04, 2012 at 12:57 AM
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.
Sure thing^^ Well, as long as it does its job... I cant find an other way to do that. Is Trigger false would be too late and it would go crazy with your box. This is the propper method to archieve this kind of behavior. At lest my propper method :D
Your answer
![](https://koobas.hobune.stream/wayback/20220613073650im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera gets flung off of the map when the player collides with certain objects. 0 Answers
Ignore sub-colliders for center of mass in Rigidbody2d? 1 Answer
Physics question 1 Answer
Physics Possibilities?: Angles, Penetration, Exceptions 4 Answers
ball's collider sometimes catches an edge and bounces. when ball rolls over two aligned platforms 1 Answer