Colliders: Is Detaching Enough?

Consider a situation in which a collider is attached to the scene graph, and further, has been added to a traverser and a CollisionHandlerPusher. (And thus is an “active”/“from” collider.)

Given this, if I want to temporarily remove the collider from the scene (such as due to it being located in a “room” far from the player), is it enough to just detach the collider (or an ancestor thereof) from the scene-graph? Or is it important to also remove the collider from the traverser and the “pusher”?

Note that this is a case in which I may well want to re-attach the collider at some later point (such as due to the player again approaching its “room”). Naturally, when I want to destroy the collider entirely I would (hopefully!) remove the collider from the traverser and collision-handler.

Or, to ask from an alternative perspective: What does Panda do with colliders that have been added to a traverser and a collision-handler, but that are not connected to the scene-graph?

When you call traverse(root) the traverser will notice that your detached “from” collider is in a different scene graph than the given root, can’t possibly generate collisions, and disable the collider. So it is an effective way to disable the collider, but I think I’d personally just do it explicitly with trav.remove_collider(...).

Ah, that’s good to read–thank you! :slight_smile:

Well, the thing is that I’m detaching the collider anyway: it generally shares a parent-node with the visual representation of whatever it is, and that parent-node is being detached.

It’s thus more convenient to rely on that than to look through my code for the various colliders that might want for removal, and further to remember to do that for future classes that might carry their own specific colliders, too…

That parent-node makes for a handy central object to which at least much of a given “logical object” is attached, allowing me to detach everything (or just about) in one fell swoop.