Character is hitting the ground but not collisions are being detected.

I am trying to make a simple test 2D platformer game. My character has gravity and falls to the ground, and when he hits the ground he stops (which I would expect to be a collision).

Here’s what I have to assure this collision happens:

  1. I have this method in my player controller script:

           private void OnCollisionEnter2D(Collision2D collision)

                if (collision.gameObject.CompareTag("Ground"))
                    isGrounded = true;
                    Debug.Log("In OnCollisionEnter2D");
                    Debug.Log("isGrounded is now " + isGrounded.ToString());

  1. The character has a 2D box collider and a 2D rigidbody. The rigidbody is Dynamic, not Kinematic.

  2. The “ground” is a tilemap with a Tile Map 2D collider (it does not have a rigidbody).

  3. Both colliders are NOT triggers.

  4. The character can jump, so the collisions should be happening everytime he falls back down.

  5. Just in case I’m using the wrong method, I also have the two methods:

OnTriggerEnter2D(Collider2D collider)

OnControllerColliderHit(ControllerColliderHit hit)

I gave them the same debug statements. Neither of them detect a collision.

The OnCollisionEnter2D (and the other likewise methods) have 0 references and are “unused” according to Visual Studio. I don’t know if that’s a problem.

With all this, I expect the Debug.Log() statements to show in the console, but they never do. I would appreciate some expert help as to why the collisions aren’t happening. If you need more insight into my project, I will gladly give it. Thanks for the help!

I think if the floor collider isn’t a trigger then it also needs to have a rigidbody2D. Just set it to kinematic.

I figured it out. I had the character’s class inheriting from KinematicObject. As soon as I changed it to MonoBehaviour, it started detecting collisions (only OnCollisionEnter2D detected).

Sorry I didn’t mention the part about KinematicObject. I figured it wouldn’t be part of the issue.