I'm creating simple car game with cannon.js and I'm struggling with this.
What I want to do:
When I run with car into another object (e.g. sphere) I want to know about it.
For example increase score or whatever, but without applying forces to both objects.
What I unsuccesfully tried:
Use
chassisBody.addEventListener("collide",function(e){ "mycode"};
with combination groups
var GROUP1 = 1; etc..
but point of groups I guess is mark which object I want and don't want to collide, and I want them to "collide" but without actually applying forces to them, only registering that their bodies intersected and firing my scoring code etc.
( I added threejs tag just in case someone might have stumbled across this, and I'm using it anyway )
EDIT 2022:
Here it is how it looks, warning, its an old code :)
The following code is taken from this example. I tested with your event listener callback and it worked fine.
Set collisionResponse
of the rigid body to 0
:
b2.collisionResponse = 0; // no impact on other bodys
b2.addEventListener("collide", function(e){ console.log("sphere collided"); } );