I’m currently utilizing the Havok physics plugin. I understand that PhysicsBody provides a callback when two physics bodies collide. However, I’m having difficulty determining when these two bodies stop colliding, or separate. Could anyone provide some guidance on how to get notified when two PhysicsBodies no longer collide?
Any assistance or insights would be much appreciated.
check the line 132~156
This isn’t a handling for two objects are separated
but I hope this helps.
Thank you, as far as I understand the API does not provide a callback for collisions that end?
Yes, there isn’t a callback for that. @eoin is this available somewhere that we could expose or is this not a very common use case?
I have a third-person character controller and a terrain, both with physics bodies. When my character jumps, they no longer collide, but when the character falls, they collide. I would like to track this state.
The WASM does write it out; just not exposed to the end interface right now, it looks like.
If you look at CollisionEvent.readToRef, it’s reading a subset of the
CollisionEvent (from HavokPhysics.d.ts) from the buffer into a JS struct. The intBuf contains the event type, so there should be events whose type is _hknp.EventType.COLLISION_FINISHED.value, which will be the “stopped colliding” event.
I’ll work on exposing that, then
FYI, we now have an observable for collision finished events! Add observable for collision finished events/trigger events by carolhmj · Pull Request #14109 · BabylonJS/Babylon.js (github.com)
It’s a separate observable so it doesn’t interfer on existing code that uses the other collision events
I used the CollISION_FINISHED incident, but no matter what, it was not triggered
Hey @carolhmj did you update the official documentation for that? So we can check the examples for finished events.
@carolhmj is currently off so be patient she ll be back soon after the summer break.
It seems that the onCollisionEndedObservable() has only been implemented in the Havok plugin itself and not on the physics body:
Physics V2 Simple scene with Aggregate | Babylon.js Playground (babylonjs.com)
Could we have this observable on the physics body too?
Certainly, I can add that