MousePick a ragdoll

Hello monkeys!

I can’t seem to get a handle on mousepicking ragdolls.

I am using KinematicRagdollControl.

My goal is to be able to show a healthbar when (and only when) the ragdoll character is mouse picked.

    Ray ray = new Ray(origin, direction);
    CollisionResults results = new CollisionResults();
    shootables.collideWith(ray, results);

    if (results.size() > 0) {
        CollisionResult closest = results.getClosestCollision();

        Quaternion q = new Quaternion();
        q.lookAt(closest.getContactNormal(), Vector3f.UNIT_Y);


I have a list of players, each with it’s own ragdoll.

The spatial that my ragdoll is attached to contains userdata with health and stuff.

Now, the collision results do not give me a geom or spatial so how can I retrieve the userdata that I put in using these results?

Closest.getGeometry() and maybe . getParent() thereof

1 Like

Nevermind, I found it.

It was the 3rd parent :smile:

Note: Don’t rely on that. Use something like:
Do { if (curr.getControl()! = null)… curr = curr.getParent(); } while(curr! = null)

1 Like

Or you can just use Lemur’s mouse picking and avoid the whole mess. :smile:

MouseEventControl.addListenersToSpatial(yourRagDollModel, new MouseListener… etc.)

Edit: or if you need the actual click location you can use CursorEventControl.

1 Like