Unity collider not working? Here is why.

Collider is the basic physics in a game. But many a times we find ourself with colliders that are not working. These are a few ways you can debug it. But if you don’t wrap up your head around the basics of collider then it might be difficult. This post is not about Unity colliders, it’s about the way to debug a nonfunctional collider. If you want to know in detail about colliders then read our other post on Unity collider.

Let’s start debugging

Confused person

Basic checks

  1. You have attached colliders to your objects.
  2. A collision requires a Rigidbody. At least one of your colliders should have a Rigidbody component.
  3. Rigidbody should not be marked as isKinematic.
  4. Understand the collision matrix below.
Rigidbody collider matrix
Source: Unity Docs

Next step: Types of Collider and functions

  1. If your collider is marked as trigger then you should use OnTriggerEnter()
  2. If your collider is not a trigger then you should use OnCollisionEnter()
  3. OnTriggerEnter should be used even if only one of your colliders is a trigger.
  4. O,T,E,C are capital letters in the OnCollisionEnter and OnTriggerEnter functions.
  5. Check if you forgot to mention the return type of OnCollisioEnter or OnTriggerEnter.(This should show as an error in Unity console or in visual studio code intelliSense)
  6. Check the spelling of the collision functions.
  7. If you are using 2D colliders then the collision functions to use or OnCollisionEnter2D and OnTriggerEnter2D.
  8. The input variable for OnCollisionEnter is Collision and for OntriggerEnter is Collider. (This should also throw an error on the console window)

If all the above is Ok, then let’s use the final tool to find out where the problem is.

The debug statement

If you have any condition inside your collision function that might be the problem. To check if Unity is detecting collision. Put in a Debug.Log statement inside your collision function and run your game.

If your console window displays the message on collision then it’s your condition that’s not working. If the debug message doesn’t show up then run through the steps above one more time.

2 thoughts on “Unity collider not working? Here is why.”

  1. What if it’s not a coding problem? My player just simply won’t enter the box collider (with IsTrigger checked). I have box collider and rigidbody on my player. If I jump onto a trigger box collider, I stand on top of it, instead of entering into it.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: