- Home /
OnTriggerEnter not being called
Hey everyone,
I've been working on a project for a while now, but I hit a bump in the road on it recently. I have an empty object with a rigidbody, box collider and some code to detect if anything enters it's collider. However, even though tons of things are entering it, OnTriggerEnter is not being called. I experimented around a bit, and I found that changing it's rigidbody component in the inspector while the game is running would make OnTriggerEnter be called. So, I tried to replicate this in my code, by changing a few variables in my rigidbody component every frame. But it still wasn't called.
Is there something that I'm missing? (Please don't be one of those guys who just tells me to get Pro, not everyone can afford it)
Answer by guavaman · Oct 23, 2014 at 03:14 AM
Check out this page: Unity Manual - Colliders Scroll to the bottom and look at the two tables. They show you what combinations of collider, trigger, rigidbody, isKinematic will collide together. Next, make sure the objects are not on collision layers that are set to ignore each other.
You saved my life with ''Next, make sure the objects are not on collision layers that are set to ignore each other.''
Thanks dude :D
thanks, but all of my GameObjects are under the same layer..the default later. could you guide me on how to rectify this?
Thank you a lot. I've tried almost everything, the problem was that none of the colliders had rigidbody.
Answer by wyckster · Dec 06, 2020 at 11:52 PM
In a 2D game it's called OnTriggerEnter2D. (...in case anyone arrives here but is using Collider2D and RigidBody2D).
Tragically, there is no complaint if you if you define OnTriggerEnter on your 2D object. It just never gets called.
Answer by DarthHawk13 · Jan 07, 2017 at 09:51 PM
This you tube tutorial by Brackeys may help : https://www.youtube.com/watch?v=STzGxHbdwgw
Also I got frustrated for about an hour earlier today asking myself the same question, Why won't collisions work anymore? Come to find out I hadn't attached the script I wrote to the gameobject... haha.
You may or may not need to mess around with collision layers. For the small demo game I'm currently making for my portfolio all my game objects are on the default layer.
Your answer
![](https://koobas.hobune.stream/wayback/20220613165730im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
[SOLVED] OnTriggerExit only called when object moves 0 Answers
OnTriggerEnter strange bug 2 Answers
How to use different and distinguish between different box colliders? 1 Answer
Mesh Collider Won't Work After Running Another Collider 2 Answers
How do i delete a gameObject if it enters a box collider using tags 2 Answers