physicsImpostor.unregisterOnPhysicsCollide not working?!

physicsImpostor.unregisterOnPhysicsCollide doesn’t seem to work Babylon.js Playground

Pinging el maestro ! @Cedric

Of course it does, when unregistering the right function :slight_smile:

https://playground.babylonjs.com/#W5SDRI#1

What you did was trying to remove a new function that is similar to the original one, but not the same. so it didnt find it.

1 Like

#RaananW But why is console.log() not printing anything?
#W5SDRI#2

because you unregister the collider, so the collider doesnt run. you register it, then unregister it, so it never triggers.

1 Like

That makes sense. Thanks

2 Likes

(Wingy hugs Arte). :slight_smile: We had no code bug, but there was an Arte brain bug, eh? :wink: I’ve had hundreds of them. MANY of my bug reports changed from “Hey, I think this is a bug”… into “Oops, I think I had a misconception.” :slight_smile:

I think maybe it is the word “register”. “register” is a term used for event “triggering” and event handlers. When the physicsEngine “registers” an onCollide event, then there MUST be a time when that event is un-registered… and this is where Arte takes a beautiful swan dive into Lake Misunderstandin. :slight_smile:

Had we used “bind” and “unbind” instead of “register” and “unregister”… hmm. Events are registered, handlers are bound. hmm. Just thinkin’… 'bout words.

@RaananW… geez, good catch on the not-identical functions being registered/unreg. Holy crap, i would have NEVER seen that. Miracle catch! (bow, bow) U been well? Hope so. You too, Arte, and everyone else.

1 Like