Howto make class specific operations on raycollisions

The title might be a litle confusing.



But what I want to do is by using “Ray collision detection” to pick and interact with a node on the scene.

The interaction from the node is defined in my LifeFormObject class that extends PhysicsCharacterNode!



So what I initially did was.



CollisionResult closestTarget = targets.getClosestCollision();

closestTarget.getGeometry().getParent(); this would return a node ( Node ).

This is actually pretty good, for my basic needs!



Then I tried to cast the node that I got up to (LifeFormObject) to be able to call it’s interact() method.

but that broke!



So what I wonder is how you guys would approach this problem?



// Krol

Never mind this :stuck_out_tongue: I figured out the easy solution!



(LifeFormObject)interactables.getChild(closestTarget.getGeometry().getParent().getName());

Don’t know if this is “THE” solution, but it’s working pretty nice for my prototype…