MousePicking Physical Nodes

Hallo there.



I could make mousepicking correctly, however im having some issues regarding on how to detect exactly what he picked.



I can detect where he picks, but not the right class.



[java]Geometry target = results.getClosestCollision().getGeometry();[/java]



So, i can know if my target is a ‘crate’ for example by its name. However, the crate is a physical object, a simple Box shape with a RigidBodyControl. I want to move the physical location of that box when the user clicks it for example, however i only have acess to his Geometry. Any tips on how could i achieve that ?



Thanx alot for any help !

If you added the rigid body control to the geometry:



[java]

Geometry target = results.getClosestCollision().getGeometry();

RigidBodyControl control = target.getControl(RigidBodyControl.class);

control.setPhysicsLocation(…);

[/java]



If you added the rigid body control to the geometry’s parent:



[java]

Geometry target = results.getClosestCollision().getGeometry();

Node parent = target.getParent();

RigidBodyControl control = parent.getControl(RigidBodyControl.class);

control.setPhysicsLocation(…);

[/java]

1 Like

You are mixing two collision detection systems here. If you want to pick physics objects you do physicsSpace.rayTest() the other stuff is geometry based and creates additional data.

1 Like

ty for the information

any cool examples on that ray test ?