Check if physic objects collide

Hi,
I need to check if two rigid bodyes collide in my update loop, there is PhysicsCollisionListener, but it only says when collision happens. I need something like rigidBody.collidesWith(anotherRigidBody). It would be a simple check like “is the ball on the ground?”
Is there any way of doing this with only rigid bodyes, not spatials?
Thanks.

you can use a PhysicsCollisionListener for this. From the PhysicsCollisionEvent parameter, you can access both the affected physics controls, and check if they collided.

You probably look for PhysicsSpace.rayTest and .sweepTest I suppose. But please do read the manual.

1 Like

Thx @normen
I tried to find it in manual but i couldnt :(.

The methods have javadoc, do you have any issues using them or finding them? When I said “read the manual” I meant reading it, not trying to find the exact answer to the question in your head.

The real problem was because i used my forces in update loop and not using PhysicsTickListener, so i dont need any rayTest because i can use PhysicsCollisionListener result. That tick listener saved my life, i was doing it all wrong :slight_smile:

1 Like