p2.js icon indicating copy to clipboard operation
p2.js copied to clipboard

Sometimes the ball goes through the collision.

Open lcsweet opened this issue 7 years ago • 6 comments

In the process of moving the ball sometimes through the collision body, the situation is the occasional occurrence.

lcsweet avatar Oct 13 '16 09:10 lcsweet

Hello, I think you need CCD but I'm not sure. A smaller time step can also help. Can you tell me more about your physics setup? Is it Circle vs Box or something else?

schteppe avatar Oct 13 '16 11:10 schteppe

The moving ball has circle and polygon, is set up:

    body.angularDamping = 0;
    body.angularForce = 0;
    body.applyDamping(0);
    body.damping = 0;

Wall is BOX Address of the game:http://xchange-cq.com/test/ http://xchange-cq.com/demo/error1.png http://xchange-cq.com/demo/error1.png

lcsweet avatar Oct 17 '16 01:10 lcsweet

I see :) Try using a thicker box, or Plane shapes for the walls instead. If a shape is too thin it will allow for pass-through if the ball has high velocity.

schteppe avatar Oct 17 '16 06:10 schteppe

CCD is a lifesaver too.

Depends on if the object needs a high velocity.

jtenner avatar Nov 10 '16 15:11 jtenner

@jtenner how did you fix it with CCD, mind give me some code?

issy123 avatar Dec 08 '16 20:12 issy123

check here

This has the code for adding continuous collision detection. It's very useful for fast moving objects that require precision.

jtenner avatar Dec 13 '16 22:12 jtenner