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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

OnCollisionStay with multiple collisions?

Discussion in 'Editor & General Support' started by ssb, Apr 7, 2014.

  1. ssb

    ssb

    Joined:
    Jul 8, 2013
    Posts:
    5
    I'm trying to make a character controller with a rigidbody and box collider. To detect if the character is on the ground, I'm running through each of the contact points and checking its normal compared to the ground layer.This works well except for when the character is in a corner/wall that is "part" of the ground, for example on a triangular ramp mesh.

    On the ground, I can find the contacts, see immediately that the normal is up, and happily determine that my player is on the ground (normal in red):

    $goodnormal.png

    Great. The box is on the ground and colliding fine. But when we nudge to the left just a bit more, into the ramp mesh (which is one piece and on the ground layer), this happens:

    $badnormal.png

    There are plenty of collisions, but it ONLY detects the collisions with the ramp and no longer collides with the ground. Why is this? How can I get it to collide with the ramp AND with the ground?
     
  2. Magison

    Magison

    Joined:
    Mar 1, 2013
    Posts:
    21
    -deleted- (misinterpreted the question)
     
    Last edited: Apr 7, 2014
  3. CJ-Clark

    CJ-Clark

    Joined:
    Jun 26, 2013
    Posts:
    4
    Did you ever resolve this? I am running into the same problem. It seems OnCollisionStay(Collision contacts) only returns at most 16 contacts and stops returning the ones on the ground when I walk up against a wall...