Hey @trevordev … I been porting some of my CannonJSPlugin supported collision event system to Ammo.js… My core collision system uses the Legacy onCollisionEvent because
of its general purpose collision event that just gives you the collider and the collidedWith objects without having to specifically register a collision event between two KNOWN physics impostors… I looked at the the code and it should be calling it. But its not. When i wrap a handler for it i get nothing:
abstractMesh.physicsImpostor.onCollideEvent = (collider, collidedWith)=>{
console.log("*** GOT THIS COLLISION ***");
};
but if i specify the impostors with:
player.physicsImpostor.registerOnPhysicsCollide(ground.physicsImpostor, function(main, collided) {
console.log("FPS IS CONTACTING GROUND");
});
that DOES WORK… Gets collision events.
Can you please look at that… Thanks Bro
Yo @trevordev … I think i found issue…
If i register a DUMMY collision using registerOnPhysicsCollide i then get my legacy onCollideEvent
The problem this code here:
if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
if (this._isImpostorInContact(mainImpostor)) {
for (var collideCallback of mainImpostor._onPhysicsCollideCallbacks) {
for (var otherImpostor of collideCallback.otherImpostors) {
if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
mainImpostor.onCollide({ body: otherImpostor.physicsBody });
otherImpostor.onCollide({ body: mainImpostor.physicsBody });
}
}
}
}
}
}
It does not take into account the mainImpostor.onCollideEvent not equal null like the physicsImpsoter.onCollide does with this code:
``
if (!this._onPhysicsCollideCallbacks.length && !this.onCollideEvent) {
return;
}
``
The current code is just checking mainImpostor._onPhysicsCollideCallback.length.
I think we need to add support for mainImposter.onCollideEvent as well… Please
1 Like
Yo @trevordev …
i see the problem… the nature of handle the collisions in the execute step only really allows for detecting collision with KNOWN physics imposter references that you have use code to always get a reference with anything you want to detect collisions with.
So … I added Global Contact Callback support to Ammo.js
Check it out… it works great for me…
I also have builds on My Ammo.js Fork until the PR goes thru
1 Like
Awesome you got it to work Let me know if you need anything from me if that gets merged.
1 Like