Search Unity

OnCollisionEnter2D seems to fail since 5.3 update.

Discussion in 'Physics' started by Raitoning, Dec 9, 2015.

  1. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    Hi everyone,

    I'm working on a Pong-like game in 2D. All physics is done with some Box Collider 2D and a RigidBody 2D on the ball. Everything worked well before. With the new update, 5.3, the game engine seems to fail to detect collisions on Box Collider 2D when they move. To be more precise, all collisions on the border of the screens works well with a Box Collider 2D, but the one on the player and the IA, also with some Box Collider 2D, seems to work completly randomly, nearly never detected, maybe around 1/10 collisions are detected. The ball bounce off everything, as if a collision is dectected.

    I've put this code on the ball:

    Code (CSharp):
    1.     void OnCollisionEnter2D (Collision2D other)
    2.     {
    3.         Debug.Log ("Collision");
    4.     }
    This code print normally when colliding with a wall, but around 1/10 or even less of the time when colliding with the player and IA. The only way to have collisions detected is to put the ball's collision detection to "Continuous" but it's overkilling some features of my game ( You can't beat the IA, the only way you have to win is to have enough chance to have the ball go trought the IA's collider at very high speed ).

    I was working on this project with the Linux beta version of the Editor, everything worked well on the 5.2.X release ( the last one ). My problems started when upgrading to 5.3 and going back to Windows.

    Thanks everybody for reading me.
    bug pong.png
     
    Last edited: Dec 9, 2015
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Could you please provide a bug report?
     
  3. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    Hello,

    I don't really know if it's a new behavior due to the 2D physic upgrade for particles or a bug, so I didn't have done a bug report. Maybe I have to do my physics with rigidbody now or by another way, I did not checked the docs if something changed. I've done it as usual I do with 2D physics.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Are you sure the problem didn't start in 5.2.3 or 5.2.3 patch release?

    There's a fix on its way but without a bug case I cannot verify that it resolves your problem.

    NOTE: Please attach a simple reproduction project to your bug report.
     
  5. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    Hi,

    I've just tried again the old version of my game on my Linux laptop using the 5.2.2f1 release ( latest Linux beta build available at this time. ) and it works just fine. The same code print on each collision. This problem appeared after I've added some 2D particles systems on my ball. I can't make a bug report right now but I will do it this afternoon around 14:00. Thanks for checking this bug if it's one.
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Just FYI, 5.2.2 isn't the latest version on 5.2.3p3 was the latest.

    The 2D particle stuff has no impact on 2D collision detection i.e. the 2D physics wasn't changed for that feature.

    Thanks for doing a bug report!
     
  7. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    If the 2D physics didn't changed, then I may have messed something in my project. I will check everything up when I'll can. I hope I did not make any error and took your time for nothing.
     
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    It's never a waste of time. All bug reports are useful. I was really just trying to highlight that the issue may have started before 5.3 being as the recent problem was there in 5.2.3p3.
     
  9. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    I did not used the 5.2.3p3 version, I've jumped from 5.2.2f1 on Ubuntu Linux to 5.3 on Windows, so I can't say if that started with the 5.2.3p3 version. If this problem started in this version, then my problem is maybe the same.
     
  10. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    Hi again, sorry for double post.

    I've just send you a bug report with a project as close as mine but with only things needed to reproduce the bug. I hope this will help you.
     
  11. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    You should eventually get an email. Let me know the bug case number and I can verify that it's fixed.
     
  12. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
    My case number is 753115.
     
  13. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    I have verified that the fix already in progress resolves your issue.

    Thanks for the bug report.
     
  14. Raitoning

    Raitoning

    Joined:
    Dec 13, 2014
    Posts:
    100
  15. bundy

    bundy

    Joined:
    Apr 14, 2013
    Posts:
    8
    I was just about to post about this as well. The problem for us started with any version past 5.2.2 as MelvMay suggested.

    One use case we're having trouble with is when a trigger is animated with Mecanim, the collision is simply not registered.
    - If a trigger is spawned on top of another animated trigger, the collision will occur.
    - If a trigger is spawned and then moved into the animated trigger, the collision will fail.

    I've attached a small test project where we can replicated this consistently on 5.3.0f4. If you open the Test scene and press space, you will see the collision fail. If you turn off the Animator component on the Target object and play the scene, the bullets will now hit without the trigger on the Target object animating.

    We're also having issues with some cases where collisions don't register post 5.2.2 without adding a Rigidbody2D on all the involved objects, but we haven't looked into this as much to provide a test case.

    Edit:

    I've submitted a separate bug report in case this is not a duplicate: 753232
     

    Attached Files:

    Last edited: Dec 11, 2015
  16. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    I just checked your case and it's fixed. It would've stopped working in 5.2.3p1.

    The fixes will be in 5.3.0p1 and 5.2.4 releases.
     
    Last edited: Dec 12, 2015
    bundy likes this.