Remove a Spatial from a Node with CollisionResults

I want that if I hit one child from the shootables that this thing will detached.
This works with geometry fine, but if I add a spatial nothing happens, how I can fix this?
Give it a better method than remove a child with their names, because it can happens that two geometrys have the same name.
Is there something like a unqiue id ?

Show at line 89!
package mygame;

import com.jme3.collision.CollisionResult;
import com.jme3.collision.CollisionResults;
import com.jme3.font.BitmapText;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Ray;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;

public class Main extends SimpleApplication
public static void main(String[] args)
Main app = new Main();

private Node shootables;
private Geometry mark;

public void simpleInitApp() 
  initCrossHairs(); // a "+" in the middle of the screen to help aiming
  initKeys();       // load custom key mappings
  initMark();       // a red sphere to mark the hit

  /** create four colored boxes and a floor to shoot at: */
  shootables = new Node("Shootables");
  shootables.attachChild(makeCube("a1", -2f, 0f, 1f));
  shootables.attachChild(makeCube("a2", 1f, -2f, 0f));
  shootables.attachChild(makeCube("a3", 0f, 1f, -2f));
  shootables.attachChild(makeCube("a4", 1f, 0f, -4f));

private void initKeys() 
    inputManager.addMapping("Shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); // trigger 2: left-button click
    inputManager.addListener(actionListener, "Shoot");

private ActionListener actionListener = new ActionListener() 
    public void onAction(String name, boolean keyPressed, float tpf) 
        if (name.equals("Shoot") && !keyPressed) 
            // 1. Reset results list.
            CollisionResults results = new CollisionResults();
            // 2. Aim the ray from cam loc to cam direction.
            Ray ray = new Ray(cam.getLocation(), cam.getDirection());
            // 3. Collect intersections between Ray and Shootables in results list.
            shootables.collideWith(ray, results);
            // 4. Print the results
            System.out.println("----- Collisions? " + results.size() + "-----");
            for (int i = 0; i < results.size(); i++) 
                // For each hit, we know distance, impact point, name of geometry.
                float dist = results.getCollision(i).getDistance();
                Vector3f pt = results.getCollision(i).getContactPoint();
                String hit = results.getCollision(i).getGeometry().getName();
                System.out.println("* Collision #" + i);
                System.out.println("  You shot " + hit + " at " + pt + ", " + dist + " wu away.");
            // 5. Use the results (we mark the hit object)
            if (results.size() > 0) {
              // The closest collision point is what was truly hit:
              CollisionResult closest = results.getClosestCollision();
              // Let's interact - we mark the hit with a red dot.
              // No hits? Then remove the red mark.

protected Spatial makeCharacter() 
    // load a character from jme3test-test-data
    Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);

    // We must add a light to make the model visible
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
    return golem;


You can use


…or you can traverse up to the right Node parent that represents the model you want to remove and remove that. There are numerous ways to do this.