I have implemented collision listener, it works great. But how to detect this:
if my node hits the floor {
remove it from scene
createExplosion();
}
I already tryed getNodeA/getNodeB but it does not work! Help?
I have implemented collision listener, it works great. But how to detect this:
if my node hits the floor {
remove it from scene
createExplosion();
}
Well, the fact that you receive a CollisionEvent means that a collision happened. Now you just have to check the name of the nodes that collided (getNodeA/getNodeB) to know which ones it were. Look at the TestPhysicsVehicle class in jbullet-jme, there is a check if the car collided with the sphere.
What works great? What does not work? What are you doing? If you successfully receive CollisionEvents (as it seems when you're calling getNodeA/B) you could compare the names of the nodes to find out if the floor and node collided here.
an, it receives the information that something collided (This works). But I don't know how to detect if the node hits something (This I don't know).
What I want to do:
Okay, just a question:
What defines who's the NodeA and who's the NodeB?
Like NodeA is the falling node and the NodeB is the floor?
all spatials have setname getname, so name your grenade "grenade" and your floor "floor" , then fi you detect that one of the nodes is named grenade the other floor, cast the grenade node to your grenadeobject and call explode
GustavoBorba said:
Okay, just a question:
What defines who's the NodeA and who's the NodeB?
Like NodeA is the falling node and the NodeB is the floor?
But I have this code:
public void collision(CollisionEvent e) {
if(e.getNodeA().equals(physicsTube) && e.getAppliedImpulse() > 18) {
rootNode.detachChildNamed("Missile");
createExplosion();
}
else if(e.getNodeB().equals(physicsTube) && e.getAppliedImpulse() > 18){
rootNode.detachChildNamed("Missile");
createExplosion();
}
}
so when nothing happens maybe your createExplosion does not work? how is it supposed to know where the explosion happens anyway? you dont seem to supply any vector for that.
No! You helped me with the eplosion normen (: And it works! It works without beaing called inside CollisionListener. It creates beattiful particles. At 50, 1, 50 (X, Z, Y).
Solved, thank you normen.