reactphysics3d icon indicating copy to clipboard operation
reactphysics3d copied to clipboard

How to use CollisionBody?

Open TheBoneJarmer opened this issue 3 years ago • 1 comments

Hey

First of all, amazing library! I have been using it for a while now and I absolute love it. Now, since an hour ago I needed the CollisionBody class for a certain case. So far I have been using the HTML docs as well as the API to learn how to use ReactPhysics3D and I have come very far with it. And while you do cover the creation and destruction of a collision body in chapter 9. You do not provide a chapter on how to actually use the class for detecting collisions. Could you pleeease be so kind to help me out here and give me some directions? :D

EDIT: To give a specific case, let's say I have two objects with each a CollisionBody with a BoxShape Collider attached. How do I test if object A collided with object B?

With kind regards, TheBoneJarmer

TheBoneJarmer avatar Jul 31 '22 19:07 TheBoneJarmer

Hello. Thanks a lot for your feedback.

You are right, there is not much information about CollisionBody in the documentation. The most important thing to know is what is written in section 8.4 "Retrieving Contacts" in the documentation. If you manually want to test for collision between two CollisionBody in order to know if they collide, you need to use one of the PhysicsWorld::testOverlap() methods. If you also want to retrieve contacts, you need to use one of the PhysicsWorld::testCollision() methods.

I hope it helps.

DanielChappuis avatar Aug 01 '22 20:08 DanielChappuis

I am closing this issue. Do not hesitate to reopen it if necessary.

DanielChappuis avatar Aug 16 '22 12:08 DanielChappuis