Search Issue Tracker

Fixed in 2021.2.X

Fixed in 2021.1.X

Votes

3

Found in

2019.4

2020.1.6f1

2021.1

Issue ID

1287916

Regression

No

ContactPoint2D.tangentImpulse sometimes returns NaN when called in OnCollisionEnter2D

Physics2D

-

How to reproduce:
1. Open the attached "case_1287916-Project" project's Scene labeled "Main"
2. Enter the Play Mode
3. Get the "Player" near to the ground
4. Flip it on the side using the "Right-Arrow" key
5. Hold "Left-Arrow" to put the Player in the upright position
6. Flip the "Player" again on the side (Space+Right-Arrow)
7. Repeat from the 5th step (2-5 tries)
8. Inspect the Console Window

Expected result: ContactPoint2D.tangentImpulse doesn't return NaN when called in OnCollisionEnter2D
Actual result: ContactPoint2D.tangentImpulse sometimes returns NaN when called in OnCollisionEnter2D

Reproducible with: 2019.4.13f1, 2020.1.13f1, 2020.2.0b11, 2021.1.0a5
Couldn't test with: 2018.4.29f1 (Project breaks)

  1. Resolution Note (fix version 2021.2):

    Fixed an issue where the contact manifold count would transition from 1 to 2 during the pre/post solve cycle. This resulted in normal/tangent impulses not being reset correctly and therefore the subsequent sum of impulses being undefined leading to bad values or NaNs being reported. Now the impulses are reset regardless of contact count. Fixed in Unity 2021.2.0a11 and above.

    Ref: https://forum.unity.com/threads/possible-unity-bug-contact-normal-is-nan-in-oncollisionenter.276770/#post-6901259

Comments (1)

  1. Menion-Leah

    Nov 05, 2020 12:32

    Same issue here (also in Unity 2018.x).

    As I side note, I discovered that in my case this behavior happens more often when I check for secondary impact points (IE: second, third, fourth.. collision points in the Collision2D.contacts array).

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.