Moving character

Hello guys. I have finished a project and I have the following problem
Everytime I try to move my character, left, right, front, back I get the following error

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at mygame.FieldofLife2.simpleUpdate(FieldofLife2.java:467)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:242)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)

What could I have done wrong?

your bug is here:
at mygame.FieldofLife2.simpleUpdate(FieldofLife2.java:467)

…but we can’t see it.

So I’m going to make a random guess answer: orangutan

This is my simpleUpdate.
I cant find the problem… any help or tip will be greatly appreciated

public void simpleUpdate(float tpf) {
Vector3f camDir = cam.getDirection().clone().multLocal(0.5f); //speed
Vector3f camLeft = cam.getLeft().clone().multLocal(0.1f);

    //System.out.println("Camera Direction" + camDir);

    camDir.y = 0;
    camLeft.y = 0;
    walkDirection.set(0, 0, 0);

    if (left) {
        walkDirection.addLocal(camLeft);
    }
    if (right) {
        walkDirection.addLocal(camLeft.negate());
    }
    if (up) {
        walkDirection.addLocal(camDir);
    }
    if (down) {
        walkDirection.addLocal(camDir.negate());
    }
    if (!character.onGround()) {
        airTime = airTime + tpf;
    } else {
        airTime = 0;
    }
    if (walkDirection.length() == 0) {
        if (!"IdleTop".equals(animationChannel.getAnimationName())) {
            animationChannel.setAnim("IdleTop", 1f);
        }
    } else {
        character.setViewDirection(walkDirection);
        if (airTime > .3f) {
            if (!"IdleTop".equals(animationChannel.getAnimationName())) {
                animationChannel.setAnim("IdleTop");
            }
        } else if (!"RunBase".equals(animationChannel.getAnimationName())) {
            animationChannel.setAnim("RunBase", 1);
            animationChannel2.setAnim("RunTop", 1);
        }
    }
    if (pursuit) {
        NPCLocation = NPC1.getPhysicsLocation();
        NPC2Location = NPC2.getPhysicsLocation();
        sinBadLocation = character.getPhysicsLocation();
        //to use with physic based characters
        NPC1.setViewDirection(sinBadLocation);
        NPC2.setViewDirection(sinBadLocation);
        //when NPC get close enough
        if (NPCLocation.distance(sinBadLocation) < PROXIMITY) {
            walkNPC = new Vector3f(0f, 0f, 0f);
          //pursuit = false;
            if (!animationChannelNPC.getAnimationName().equals("push")) {
            animationChannelNPC.setAnim("push");
            }
        } else {
            //if enemy too far from Proximity 
            //if the channel does not have the walk
            if (!animationChannelNPC.getAnimationName().equals("Walk")) {
                animationChannelNPC.setAnim("Walk");                    
            }
            walkNPC = sinBadLocation.subtract(NPCLocation).multLocal(0.01f);
            NPC1.setViewDirection(walkNPC.mult(0.1f));             
        }
        
        if (NPC2Location.distance(sinBadLocation) < PROXIMITY) {
            walkNPC = new Vector3f(0f, 0f, 0f);
          //pursuit = false;
            if (!animationChannelNPC2.getAnimationName().equals("push")) {           
            animationChannelNPC2.setAnim("push");           
            }
        } else {
            //if enemy too far from Proximity 
            //if the channel does not have the walk
            if (!animationChannelNPC2.getAnimationName().equals("Walk")) {
                animationChannelNPC2.setAnim("Walk");                   
            }
            walkNPC = sinBadLocation.subtract(NPCLocation).multLocal(0.01f);
            NPC2.setViewDirection(walkNPC.mult(0.1f));
        }  
        if (NPC3Location.distance(sinBadLocation) < PROXIMITY) {
            walkNPC = new Vector3f(0f, 0f, 0f);
          //pursuit = false;
            if (!animationChannelNPC3.getAnimationName().equals("push")) {           
            animationChannelNPC3.setAnim("push");           
            }
        } else {
            //if enemy too far from Proximity 
            //if the channel does not have the walk
            if (!animationChannelNPC3.getAnimationName().equals("Walk")) {
                animationChannelNPC3.setAnim("Walk");                   
            }
            walkNPC = sinBadLocation.subtract(NPCLocation).multLocal(0.01f);
            NPC3.setViewDirection(walkNPC.mult(0.1f));
        }            
    }
    character.setWalkDirection(walkDirection);
    NPC1.setWalkDirection(walkNPC);
    NPC2.setWalkDirection(walkNPC); 
    NPC3.setWalkDirection(walkNPC);
}

at mygame.FieldofLife2.simpleUpdate(FieldofLife2.java:467)

What is line 467?

Do you understand how NullPointerExceptions (or exceptions in general) work? NPEs specifically tell you exactly where the problem is. But we can’t see the line numbers so you will have to somehow illustrate which line is 467… something in that line is null that you don’t expect it to be.

The problem seemed to be that it couldn’t perform one of Sinbad’s animations. I changed that line and solved the problem, but another one occured.

Again its a nullPointException
java.lang.NullPointerException
at mygame.FieldofLife2.onAction(FieldofLife2.java:211)
at com.jme3.input.InputManager.invokeActions(InputManager.java:169)
at com.jme3.input.InputManager.onKeyEventQueued(InputManager.java:455)
at com.jme3.input.InputManager.processQueue(InputManager.java:831)
at com.jme3.input.InputManager.update(InputManager.java:883)
at com.jme3.app.Application.update(Application.java:604)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)

and the line 211 is the pick2.collideWith(ray, results); which is contained in the following method

if (binding.equals(“pickup”)) {

    CollisionResults results = new CollisionResults();
    Ray ray = new Ray(cam.getLocation(), cam.getDirection());
    pick1.collideWith(ray, results);
    <strong>pick2.collideWith(ray, results);</strong>
    System.out.println("----- Collisions? " + results.size() + "-----");       
    for(int i=0; i&lt;results.size(); i++){
      float dist = results.getCollision(i).getDistance();
      Vector3f pt = results.getCollision(i).getContactPoint();
      String hit = results.getCollision(i).getGeometry().getName();
      System.out.println("* Collision #" + i);
      System.out.println("  You shot " + hit + " at " + pt + ", " + dist + " wu away.");
    }
    if (results.size() &gt; 0) {           
        CollisionResult closest = results.getClosestCollision();            
        Geometry g = closest.getGeometry ();             
        Node p=g.getParent();
        Node q=p.getParent();
        System.out.println ("Parent of shot object="+p);
        System.out.println ("Grandparent of the shot object="+q);
       if ((p==pick1) || (q==pick1)) {
       if (p==pick1) 
            pick1.detachChild(g);
       else if (q==pick1) { 
            pick1.detachChild(p);
        }              
            }                                       
       if ((p==pick2) || (q==pick2)) {
       if (p==pick2) 
            pick2.detachChild(g);
       else if (q==pick2) { 
            pick2.detachChild(p);
        }

pick2.collideWith(ray, results);

pick2 is null.

Thanks very much guys I solved this problem with your guidance. I am very noob in JMonkey.