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. Dismiss Notice

Quick 2d physics collision enter/exit question

Discussion in '2D' started by mike950, Jun 3, 2014.

  1. mike950

    mike950

    Joined:
    Sep 30, 2012
    Posts:
    94
    Hi I was wondering if it's possible to have 2 collision enter calls on the same object by the same object without a collision exit call? Maybe a bug if it does occur?
     
  2. Pyrian

    Pyrian

    Joined:
    Mar 27, 2014
    Posts:
    301
    Are you talking GameObject, or Collider, or something else? I don't think it should happen for a single collider, I know it can happen to a GameObject.
     
  3. mike950

    mike950

    Joined:
    Sep 30, 2012
    Posts:
    94
    Ah thanks for the reply. Each gameobject has a 2d collider attached and a rigidbody2d attached. And a script attached to handle the callbacks.
     
  4. Pyrian

    Pyrian

    Joined:
    Mar 27, 2014
    Posts:
    301
    In that case, yeah, I don't think you should be seeing two enters without an exit.
     
  5. mike950

    mike950

    Joined:
    Sep 30, 2012
    Posts:
    94
    Ah thanks for that! Usually when I see such a basic problem I figure it must be something I'm doing wrong since the physics 2d feature has been out for a while now and people would have surely found it..maybe I'm still doing something wrong?
     
  6. Pyrian

    Pyrian

    Joined:
    Mar 27, 2014
    Posts:
    301
    Heheh, always something to think about. So, no child game objects with colliders? Is there anything activating or deactivating colliders based on the collision?
     
  7. mike950

    mike950

    Joined:
    Sep 30, 2012
    Posts:
    94
    Nah it's pretty simple. I increment a counter on collision enter and decrement the counter on exit. So I figure it should never say "2". Also one is a circle collider and the other is a concave polygon collider.
    Also unrelated the forum is underlining perfectly spelled words lol...driving me crazy!
     
  8. Pyrian

    Pyrian

    Joined:
    Mar 27, 2014
    Posts:
    301
    Concave polygon, eh? So maybe it's getting two calls for hitting two different edges without having left the first one yet? I don't know, I'm just speculating.
     
  9. mike950

    mike950

    Joined:
    Sep 30, 2012
    Posts:
    94
    Thank you! I bet that's it. Can you place a tip button next to your name here?
    One thing though I wonder if that's proper behavior? I'm trying to imagine the ball rolling down a hill where it's on one edge then it enters the next edge while still on the current edge therefore generating a new collision enter. I wonder if that should generate a new collision enter?
    Great thank you very much!