Collision Listener NullPointerException

I’m currently working on creating a appstate that controls multiple AI. I use a linked list of a class AIComponent of which each AI character is created and kept track of. When one is shoot it will turn from CharacterControl to KinematicRagdollControl using this.



[java] public void collision(PhysicsCollisionEvent event) {

if (Model.equals(event.getNodeA()) || Model.equals(event.getNodeB())) {

—> if ( “bullet”.equals(event.getNodeB().getName()) || “bullet”.equals(event.getNodeB().getName())

|| “bomb”.equals(event.getNodeA().getName()) || “bomb”.equals(event.getNodeB().getName())) {



if (physicsCharacter.isEnabled()) {



physicsCharacter.setEnabled(false);

ragdoll.setEnabled(true);

ragdoll.setRagdollMode();





}



}



}



}

[/java]



When a physics Character AI comes in contact with a Ragdoll AI i get the exception NullPointerException at the line with the arrow…but my character control can collide with the ragdoll without the error occurring. The Model node is named and so is the Model itself. It is as if switching to ragdoll does not inherit the models name. Does anyone know why this is happening? Or maybe an idea of how to fix it. I’m completely stumped.



Thanks!

do all your spatials have names (not even sure its a problem), you could also brute force it with [java]if (event.getNodeA() == null || event.getNodeB == null) return;[/java]

Thanks for the reply. That’s exactly how i did it and it works great!