Do something if collided with special object?

I don’t know how to explain this, but what I need simply is that if the player collides with Enemy A, void A is called and if the player collides with Enemy B, void B is called.

Everything I found regarding collision was only about the physics (e.g. stand on something, or wall-like behavior)

Would be nice if someone could help me out :stuck_out_tongue:

Look into this

the collision listener seems appropriate. How you know what ‘Node’ is Enemy A is up to your application, you can for example store some application specific information using setUserData.

If they’re not rigid body controls, character controls, etc. then you should use Bounding Volumes. Just track their positions in the update loop, and if they’re within each other’s volumes, call A or B. The person above said you could set a user data field to help figure out which AI it collided with. Just say something like:


spatial.setUserData(“ID”, 1);


Then, when you find that your player’s bounding volume is intersecting another bounding volume, call:


if((Integer)collidedSpatial.getUserData(“ID”) == 1) {


} else if… {



That’s how I’d do it. :stuck_out_tongue: