Skip to content

Contact between a ball and cuboid sometimes and has no contact pair #255

Open
@Dooskington

Description

@Dooskington

Not sure if this is only reproducible with a Ball hitting a Cuboid, but I have not tested two Cuboids or other shapes.

Essentially, with my cuboid colliders and ball rigidbody, every once in a while the ball will collide and have no contact pair when I query. This means I can't react to the collision properly and my game just kind of breaks. It is strange though, because the rigidbody is reacting to the collision, either stopping in its place, or sliding along the box collider that it hit.

I made my game repo public with a repro branch here, and the physics code is here. The ball (created in ball.rs) has a mass of 1.0 and the rest of the colliders and paddle are just boxes set up in game/mod.rs.

If you manage to compile and run it and want to actually repro, use A/D or Left/Right to move the paddle, and spacebar to launch the ball. This seems to be easiest to repro if you just bounce the ball back and forth on the Y axis, hitting the paddle (collider index 0) and the brick directly above. Eventually, the ball will reflect strangely or stop entirely and you can observe that no contact pair was found:

contact started: handle1: Index { index: 54, generation: 0 }, handle2: Index { index: 0, generation: 0 }
No contact pair found for collision!

If you enable the println!() under the physics.step(), we can see that this isn't a case of a contact event starting and stopping on the same step (there would be a 'contact stopped' logged):

step
contact started: handle1: Index { index: 54, generation: 0 }, handle2: Index { index: 0, generation: 0 }
No contact pair found for collision!
step
step

Messing with the ccd parameters doesn't seem to help. Disabling CCD seems to improve the situation but does not fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions