Detaching nodes and collisions

Hello everyone! I'm trying to make a simple golf game and I'm having some problems with collisions.

I put a flag in the place where the hole is, but I need to detach this node when the player gets near the hole area.

I detach the flag node from the scene, but objects still collide with it (even though it doesn't render).

I guess I'm missing something here, but I've tried everything and have no more ideas.

Does anybody know what can I do to fix this?


you also need to remove the node from the physics world, only detaching it from the scene is not enough.

try physicsnode.setActive(false).

Thanks core, i tried what you suggested but the problem remains.

I've also tried setActive(false) on all the children of the node and even the parent. I've even detached them all and still have invisible but collidable objects  :?

Do you know any workaround that may work?

It should work.

I've also tried setActive(false) on all the children of the node and even the parent

Do you attach different PhysicsNodes to each other? i think that's not supported (not quite sure though). Better only attach physicNode to Nodes not other PhysicNodes.

Pressing SPACE lets the small box fall through the floor.

public class TestSimplePhysics extends SimplePhysicsGame {
   private StaticPhysicsNode floor;

   protected void simpleInitGame() {
      /* create the floor */
      Box b = new Box("floor", new Vector3f(), 100, 100, 1);
      b.setModelBound(new BoundingBox());
      b.getLocalRotation().multLocal(new Quaternion().fromAngleAxis(FastMath.DEG_TO_RAD*90, Vector3f.UNIT_X));
      floor = getPhysicsSpace().createStaticNode();
      floor.getLocalTranslation().y -= 2;
      /* add another Box */
      b = new Box("floor", new Vector3f(), 1, 1, 1);
      b.setModelBound(new BoundingBox());
      DynamicPhysicsNode box = getPhysicsSpace().createDynamicNode();
      box.getLocalTranslation().y += 10;
      // set up a key to remove the floor
      KeyBindingManager.getKeyBindingManager().add("remove_floor", KeyInput.KEY_SPACE);
   protected void simpleUpdate() {
      if (KeyBindingManager.getKeyBindingManager().isValidCommand("remove_floor", false) == true) {
         // remove from physics world
         // remove from visual scene
   public static void main(String[] args) {
      TestSimplePhysics game = new TestSimplePhysics();

Thanks core! I think I'm messing things up by attaching physics nodes to each other as you say. I'll try to fix my scene graph and see what happens.

Thanks a LOT for your help!!!  :smiley: