Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 5.2 OnTriggerEnter2D entering when it shouldn't

Discussion in 'Physics' started by Dunmord, Sep 8, 2015.

  1. Dunmord

    Dunmord

    Joined:
    Aug 15, 2013
    Posts:
    40
    Hi,

    I'm working on a project for fun. I'm making Megaman X on Unity. The problem I'm having is: a sprite is colliding with a BoxCollider2D when it shouldn't. You can clearly see on the scene that it shouldn't be colliding.

    I just upgraded to Unity 5.2. This didn't happen in the 5.1.3 patch, but it didn't happen in 5.1.2.

    The project can be downloaded here: https://github.com/Dunmord/UnityMegamanX/
    The scene is called "Level1".

    There is a collider I called "Bottom Map Limit". This collider destroys anything that touches it. It's so objects that fall dont stay alive and so the main character gets destroyed once it falls off the level.

    This is the scenario:
    1. Open "Level1"
    2. Hit Play
    3. Move left, with left,down,up,right arrows of your keyboard, until you hit a trigger.
    4. You'll activate a trigger that spawns a Ship.
    5. You'll notice the ship spawns enemies. The first enemy spawns without getting destroyed. But the second and third get destroyed, the frame after they spawn, by the collider I set at the bottom of the level.

    How do I know it's colliding with the "Bottom Map Limit"? - Because of a Debug.Log I placed.

    This is the message that shows on the console when the limit collides my enemies
    Code (CSharp):
    1. Enemy - Road Attacker(Clone) (UnityEngine.GameObject),1000000,Bottom Map Limit (UnityEngine.GameObject),Bottom Map Limit (UnityEngine.GameObject)
    2. UnityEngine.MonoBehaviour:print(Object)
    3. Hitpoints:Damage(Single, GameObject, GameObject) (at Assets/MegamanX/Scripts/Hitpoints.cs:17)
    4. MapLimit:OnTriggerEnter2D(Collider2D) (at Assets/MegamanX/Scripts/MapLimit.cs:23)
    What I want to know is if my setup is wrong somehow or is this a bug from Unity?

    Thanks,
    Dunmord