Search Issue Tracker

Duplicate

Votes

1

Found in

2017.2.0b7

2017.2.0f3

Issue ID

970859

Regression

No

Collisions between Rigidbodies with Continuous collision detection is broken

Physics

-

The physics engine does not properly handle collision detection in certain cases between "Continuous Dynamic" Rigidbodies and "Kinematic Continuous" Rigidbodies

To reproduce:

1. Download attached project "ContinuousDynamicRigidbodyVsKinematicContinuousRigidbodyCollisionBug.zip" and open in Unity
2. Open "TestScene" scene
Note: Observe Hierarchy - there is a "Capsule" gameObject with Rigidbody that is set to "Continuous Dynamic" Collision Detection. In "OscillationPivot" gameObject there is a "Box" gameObject with a Kinematic Rigidbody which is set to "Continuous" Collision Detection
3. Enter Play mode
Note: Observe that the "Capsule" gameObject get an impulse causing it to move towards the "Box" gameObject at a constant speed. The "Box" will begin oscillating back and forth according to a Sine Wave. Later, the "Capsule" appears to collide with the "Box" when they aren't actually touching and the "Capsule" appears to stop (despite having a non-zero velocity). Also, observe that there are rapid OnCollisionEnter/Exits being sent. As the "Box" oscillates back towards the "Capsule", observe that the "Capsule" phases through the "Box" and then get shot out through the side of the "Box"

Notes:
- This issue appears on Windows and OSX
- The capsule has "Continuous Dynamic" detection, non-kinematic and no gravity. It is moved with a single Rigidbody.velocity = ... in Awake
- The box has "Continuous" detection and is kinematic. Its position is set every FixedUpdate with a Rigidbody.MovePosition call
- This behavior only happens with specific scene setups (like the one on this project). It seems to depend on the speeds of the involved Rigidbodies and the size of their Colliders.
- Workaround: If you disable "Continuous" Collision Detection on the "Capsule" or if you set the "Box" to "Discrete" Collision Detection, the collision resolves as expected

Reproduced on Unity 2017.2.0b7, 2017.2.0p2, 2017.3.0b10 and 2018.1.0a5
Not reproduced on Unity 2017.1.1p2 and 2017.2.0b6
Regression on Unity 2017.2.0b7

Comments (1)

  1. jonagill_rr

    Apr 17, 2018 23:43

    We encountered our own version of this bug. In this repro we made, a kinematic cube is moved around a dynamic sphere with MovePosition(). If you let it run for a couple of seconds, it will quickly collide with the sphere (despite being almost half a meter away), and the game will pause.

    You can download the repro here:
    https://drive.google.com/file/d/1YdOZYAo8CSYatt9-2fAegBsI9WUcpZAU/view?usp=sharing

    I've attached a screenshot of the repro. Here you can see the cube and the sphere rendered with the physics debugger. A line is drawn from the center of each object to a collision point, which you can see is accurately on the surface of the sphere, but nowhere near the kinematic cube.

    You can view that image here: https://drive.google.com/file/d/1AnHtEUqUAIUKl8VkbZmsJm15K2TDHr5S/view?usp=sharing

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.