Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug? OnCollisionStay2D not reporting all contact points in corners

Discussion in '2D' started by Sir-Spunky, Jan 15, 2017.

  1. Sir-Spunky


    Apr 7, 2013
    I have a character with a BoxCollider2D and a Rigidbody2D, as well as a tilemap (made with Super Tilemap Editor from the Asset Store) that uses a single EdgeCollider2D (it generates one EdgeCollider2D per 60x60 tiles).

    In the character controller I detect if the character is grounded by checking the normals of the contact points in OnCollisionStay2D to see if one of the contact points is below the character. This works fine most of the time, as it can separate walls from ground based on the angle of the collision.

    However, when jumping against a wall and landing on the floor while still touching the wall (i.e. landing in a corner), the character is not identified as grounded. When I log the contact points in OnCollisionStay2D, it seems as if the ground is not identified as a new contact point when the character lands, if the character is also touching a wall.

    This seems strange, because the collision apparently happens, as I can see that the character stops and doesn't fall through the floor. So it apparently makes contact with the floor, but this is not reported as a new contact point.

    Any ideas what could be causing this?