Enemy rigidbodycontrol going through wall

i have a rigidbodycontrol that is an enemy with a mass and it comes towards the player. the one side has a wall rigidbodycontrol with mass zero, but the enemies go through the walls. heres my code:



pre type="java"
package megaman;





import com.jme3.app.SimpleApplication;


import com.jme3.audio.AudioNode;


import com.jme3.math.Vector3f;


import com.jme3.bullet.BulletAppState;


import com.jme3.bullet.control.RigidBodyControl;


import com.jme3.bullet.collision.shapes.;


import com.jme3.bullet.util.CollisionShapeFactory;


import com.jme3.scene.Node;


import com.jme3.bullet.control.CharacterControl;


import com.jme3.bullet.control.GhostControl;


import com.jme3.collision.CollisionResults;


import com.jme3.effect.ParticleEmitter;


import com.jme3.effect.ParticleMesh;


import com.jme3.font.BitmapText;


import com.jme3.input.KeyInput;


import com.jme3.input.controls.ActionListener;


import com.jme3.input.controls.KeyTrigger;


import com.jme3.input.controls.MouseButtonTrigger;


import com.jme3.light.AmbientLight;


import com.jme3.material.Material;


import com.jme3.material.RenderState.BlendMode;


import com.jme3.math.ColorRGBA;


import com.jme3.math.FastMath;


import com.jme3.math.Matrix3f;


import com.jme3.math.Matrix4f;


import com.jme3.math.Quaternion;


import com.jme3.math.Ray;


import com.jme3.math.Vector2f;


import com.jme3.renderer.Camera.FrustumIntersect;


import com.jme3.renderer.queue.RenderQueue.Bucket;


import com.jme3.scene.Geometry;


import com.jme3.scene.Mesh;


import com.jme3.scene.Spatial;


import com.jme3.scene.shape.Box;


import com.jme3.scene.shape.Quad;


import com.jme3.scene.shape.Sphere;


import com.jme3.system.AppSettings;


import com.jme3.texture.Texture;


import com.jme3.ui.Picture;


import com.jme3.ui.Picture;


import com.jme3.util.SkyFactory;





public class aiMap extends SimpleApplication implements ActionListener {





    boolean left, right, up, down, _RELOAD, shoot, crouch, nextWep, imReloading = false, sendGunUp = false, goright = true, goleft = false, goup = true, godown = false, cantStrafe = false;


    CharacterControl player;


    RigidBodyControl landscape;


    BulletAppState bulletAppState;


    Vector3f walkDirection = new Vector3f();


    AudioNode shootSFX, reloadSFX;


    ParticleEmitter spark;


    int updateDelay = 0, e1frame = 0, recoil, testWeapons = 0, rolly = 0, rollery = 0, reloadTimer = 250, crouchCounter = 0, bulletTimer = 0, rollUpdater = 0, gunUpdater = 0, gunUpdater2 = 0;


    Node camNode;


    float m16_x, m16_y, m16_z, recx = 0, recy = 0, recoil_z = 0;


    AmbientLight light;


    CapsuleCollisionShape capsule1, capsule2;


    Spatial ak, aug, mp5, m4a1, m16;


    Geometry floor;


    Material rupeeSkin;


    Geometry rupee;


    Geometry[] soldiers = new Geometry[15];


    Material solMat;


    RigidBodyControl[] soldierBody = new RigidBodyControl[15];


    float[] soldiersHealth = new float[soldiers.length];





    public static void main(String[] args) {


        aiMap app = new aiMap(); //Create a class object and start the app


        AppSettings settings = new AppSettings(true);


        settings.setFrameRate(60);


        settings.setHeight(600);


        settings.setWidth(800);


        app.setSettings(settings);


        app.start(); //Start the app to play the game


    }





    public void loadSound() {


        shootSFX = new AudioNode(assetManager, “Guns/fire2.wav”);


        shootSFX.setPitch(0.5f);


        reloadSFX = new AudioNode(assetManager, “Guns/reload2.wav”);


    }


    /All of the 2D image initialization stuff goes in this method./


    BitmapText ammoText;


    float ammo = 30, totalAmmo = 90;





    public void loadImage() {


        guiNode.detachAllChildren();


        BitmapText kk = new BitmapText(guiFont, false);


        kk.setSize(guiFont.getCharSet().getRenderedSize() 
 1.5f);


        kk.setColor(ColorRGBA.Red);


        kk.setText("+");


        kk.setLocalTranslation(settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3  2,


                settings.getHeight() / 2 - 50 + kk.getLineHeight() 
 2, 0);


        guiNode.attachChild(kk);


        ammoText = new BitmapText(guiFont, false);


        ammoText.setSize(guiFont.getCharSet().getRenderedSize()  1.5f);


        ammoText.setText(Float.toString(ammo));


        ammoText.setLocalTranslation(50, 300, 0);


        guiNode.attachChild(ammoText);


    }





    @Override


    public void simpleInitApp() {





        flyCam.setMoveSpeed(200);


        loadImage();


        loadSound();


        audioRenderer.playSource(shootSFX);


        loadKeys();


        bulletAppState = new BulletAppState(); //Create the physics object


        stateManager.attach(bulletAppState); //Attach the physics object to the game


        bulletAppState.getPhysicsSpace().setGravity(new Vector3f(0f, -1f, 0f));


        //Survival Mode :D


        light = new AmbientLight();


        light.setColor(ColorRGBA.White);


        rootNode.addLight(light);





        Box floorBox = new Box(Vector3f.ZERO, 130, 0, 130);


        floorBox.scaleTextureCoordinates(new Vector2f(1, 1));


        floor = new Geometry(“Floor Mesh”, floorBox);


        Material meshMat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        meshMat.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/mesh.png”));


        floor.setMaterial(meshMat);


        RigidBodyControl floorBody = new RigidBodyControl(0);


        floor.addControl(floorBody);


        bulletAppState.getPhysicsSpace().add(floorBody);





        Material concrete = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        concrete.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/Hospital/hospital_concrete.png”));





        Material concreteFloor = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        concreteFloor.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/Hospital/ConcreteFloorL.png”));





        Material concreteFloor2 = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        concreteFloor2.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/Hospital/ConcreteFloorL2.png”));





        Material concreteFloorStraight = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        concreteFloorStraight.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/Hospital/ConcreteFloorStraight.png”));





        Material concreteFloorStraight2 = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        concreteFloorStraight2.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/Hospital/ConcreteFloorH.png”));





        Material concreteFaceless = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        concreteFaceless.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/Hospital/ConcreteFloor.jpg”));





        Box wallBox = new Box(Vector3f.ZERO, 15, 10, 0);








        Geometry floor1 = new Geometry(“Floor Piece 1”, wallBox);


        floor1.setMaterial(concreteFloor);


        floor1.rotate(90 
 FastMath.DEG_TO_RAD, -90  FastMath.DEG_TO_RAD, 0);


        floor1.move(-5, 0, -15);


        rootNode.attachChild(floor1);





        Geometry floor2 = new Geometry(“Floor Piece 2”, wallBox);


        floor2.setMaterial(concreteFloorStraight);


        floor2.rotate(floor1.getLocalRotation());


        floor2.move(floor1.getLocalTranslation().x + 20, 0, -15);


        rootNode.attachChild(floor2);





        Geometry floor3 = new Geometry(“Floor Piece 3”, wallBox);


        floor3.setMaterial(concreteFloorStraight);


        floor3.rotate(floor2.getLocalRotation());


        floor3.move(floor2.getLocalTranslation().x + 20, 0, -15);


        rootNode.attachChild(floor3);





        Geometry floor4 = new Geometry(“Floor Piece 4”, wallBox);


        floor4.setMaterial(concreteFloorStraight);


        floor4.rotate(floor3.getLocalRotation());


        floor4.move(floor3.getLocalTranslation().x + 20, 0, -15);


        rootNode.attachChild(floor4);





        Geometry floor5 = new Geometry(“Floor Piece 5”, wallBox);


        floor5.setMaterial(concreteFloorStraight);


        floor5.rotate(floor4.getLocalRotation());


        floor5.move(floor4.getLocalTranslation().x + 20, 0, -15);


        rootNode.attachChild(floor5);





        Geometry floor6 = new Geometry(“Floor Piece 6”, wallBox);


        floor6.setMaterial(concreteFloor2);


        floor6.rotate(90 
 FastMath.DEG_TO_RAD, 90  FastMath.DEG_TO_RAD, 0);


        floor6.move(floor5.getLocalTranslation().x + 20, 0, -15);


        rootNode.attachChild(floor6);





        Geometry floor7 = new Geometry(“Floor Piece 7”, wallBox);


        floor7.setMaterial(concreteFaceless);


        floor7.rotate(floor6.getLocalRotation());


        floor7.move(floor2.getLocalTranslation().x, 0, -45);


        rootNode.attachChild(floor7);





        Geometry floor8 = new Geometry(“Floor Piece 8”, wallBox);


        floor8.setMaterial(concreteFaceless);


        floor8.rotate(floor7.getLocalRotation());


        floor8.move(floor3.getLocalTranslation().x, 0, -45);


        rootNode.attachChild(floor8);





        Geometry floor9 = new Geometry(“Floor Piece 9”, wallBox);


        floor9.setMaterial(concreteFaceless);


        floor9.rotate(floor8.getLocalRotation());


        floor9.move(floor4.getLocalTranslation().x, 0, -45);


        rootNode.attachChild(floor9);





        Geometry floor10 = new Geometry(“Floor Piece 10”, wallBox);


        floor10.setMaterial(concreteFaceless);


        floor10.rotate(floor9.getLocalRotation());


        floor10.move(floor5.getLocalTranslation().x, 0, -45);


        rootNode.attachChild(floor10);





        Geometry floor11 = new Geometry(“Floor Piece 11”, wallBox);


        floor11.setMaterial(concreteFloorStraight2);


        floor11.rotate(floor10.getLocalRotation());


        floor11.move(floor6.getLocalTranslation().x, 0, -45);


        rootNode.attachChild(floor11);





        Geometry floor12 = new Geometry(“Floor Piece 12”, wallBox);


        floor12.setMaterial(concreteFaceless);


        floor12.rotate(floor11.getLocalRotation());


        floor12.move(floor7.getLocalTranslation().x, 0, -75);


        rootNode.attachChild(floor12);





        Geometry floor13 = new Geometry(“Floor Piece 13”, wallBox);


        floor13.setMaterial(concreteFaceless);


        floor13.rotate(floor12.getLocalRotation());


        floor13.move(floor8.getLocalTranslation().x, 0, -75);


        rootNode.attachChild(floor13);





        Geometry floor14 = new Geometry(“Floor Piece 14”, wallBox);


        floor14.setMaterial(concreteFaceless);


        floor14.rotate(floor13.getLocalRotation());


        floor14.setLocalTranslation(floor9.getLocalTranslation().x, 0, -75);


        rootNode.attachChild(floor14);





        Geometry floor15 = new Geometry(“Floor Piece 15”, wallBox);


        floor15.setMaterial(concreteFaceless);


        floor15.rotate(floor14.getLocalRotation());


        floor15.setLocalTranslation(floor10.getLocalTranslation().x, 0, -75);


        rootNode.attachChild(floor15);





        Geometry floor16 = new Geometry(“Floor Piece 16”, wallBox);


        floor16.setMaterial(concreteFloorStraight2);


        floor16.rotate(floor15.getLocalRotation());


        floor16.setLocalTranslation(floor11.getLocalTranslation().x, 0, -75);


        rootNode.attachChild(floor16);





        Geometry floor17 = new Geometry(“Floor Piece 17”, wallBox);


        floor17.setMaterial(concreteFloor2);


        floor17.rotate(90 
 FastMath.DEG_TO_RAD, 270  FastMath.DEG_TO_RAD, 0);


        floor17.setLocalTranslation(floor1.getLocalTranslation().x, 0, -75 - 30);


        rootNode.attachChild(floor17);





        Geometry floor18 = new Geometry(“Floor Piece 18”, wallBox);


        floor18.setMaterial(concreteFloorStraight);


        floor18.rotate(90 
 FastMath.DEG_TO_RAD, 90  FastMath.DEG_TO_RAD, 0);


        floor18.setLocalTranslation(floor2.getLocalTranslation().x, 0, -75 - 30);


        rootNode.attachChild(floor18);





        Geometry floor19 = new Geometry(“Floor Piece 19”, wallBox);


        floor19.setMaterial(concreteFloorStraight);


        floor19.rotate(floor18.getLocalRotation());


        floor19.setLocalTranslation(floor3.getLocalTranslation().x, 0, -75 - 30);


        rootNode.attachChild(floor19);





        Geometry floor20 = new Geometry(“Floor Piece 20”, wallBox);


        floor20.setMaterial(concreteFloorStraight);


        floor20.rotate(floor19.getLocalRotation());


        floor20.setLocalTranslation(floor4.getLocalTranslation().x, 0, -75 - 30);


        rootNode.attachChild(floor20);





        Geometry floor21 = new Geometry(“Floor Piece 21”, wallBox);


        floor21.setMaterial(concreteFloorStraight);


        floor21.rotate(floor20.getLocalRotation());


        floor21.setLocalTranslation(floor5.getLocalTranslation().x, 0, -75 - 30);


        rootNode.attachChild(floor21);





        Geometry floor22 = new Geometry(“Floor Piece 22”, wallBox);


        floor22.setMaterial(concreteFloor);


        floor22.rotate(floor21.getLocalRotation());


        floor22.setLocalTranslation(floor6.getLocalTranslation().x, 0, -75 - 30);


        rootNode.attachChild(floor22);





        Geometry floor23 = new Geometry(“Floor Piece 23”, wallBox);


        floor23.setMaterial(concreteFloorStraight2);


        floor23.rotate(90 
 FastMath.DEG_TO_RAD, -90  FastMath.DEG_TO_RAD, 0);


        floor23.move(floor1.getLocalTranslation().x, 0, -45);


        rootNode.attachChild(floor23);





        Geometry floor24 = new Geometry(“Floor Piece 24”, wallBox);


        floor24.setMaterial(concreteFloorStraight2);


        floor24.rotate(floor23.getLocalRotation());


        floor24.move(floor1.getLocalTranslation().x, 0, floor23.getLocalTranslation().z - 30);


        rootNode.attachChild(floor24);





        Geometry floor25 = new Geometry(“Floor Piece 25”, wallBox);


        floor25.setMaterial(concreteFaceless);


        floor25.rotate(90 
 FastMath.DEG_TO_RAD, 0, 0);


        floor25.move(-30, 0, -40);


        rootNode.attachChild(floor25);





        Geometry floor26 = new Geometry(“Floor Piece 26”, wallBox);


        floor26.setMaterial(concreteFaceless);


        floor26.rotate(floor25.getLocalRotation());


        floor26.move(-30, 0, -60);


        rootNode.attachChild(floor26);





        Geometry floor27 = new Geometry(“Floor Piece 27”, wallBox);


        floor27.setMaterial(concreteFaceless);


        floor27.rotate(floor26.getLocalRotation());


        floor27.move(-30, 0, -80);


        rootNode.attachChild(floor27);





        Geometry wall1 = new Geometry(“Wall 1”, wallBox);


        wall1.setMaterial(meshMat);


        wall1.move(0, 10, 0);


        rootNode.attachChild(wall1);





        Geometry wall2 = new Geometry(“Wall 2”, wallBox);


        wall2.setMaterial(concrete);


        wall2.move(30, 10, 0);


        rootNode.attachChild(wall2);





        Geometry wall3 = new Geometry(“Wall 3”, wallBox);


        wall3.setMaterial(concrete);


        wall3.move(60, 10, 0);


        rootNode.attachChild(wall3);





        Geometry wall4 = new Geometry(“Wall 4”, wallBox);


        wall4.setMaterial(concrete);


        wall4.move(90, 10, 0);


        rootNode.attachChild(wall4);





        Geometry wall5 = new Geometry(“Wall 5”, wallBox);


        wall5.setMaterial(concrete);


        wall5.rotate(0, 90  FastMath.DEG_TO_RAD, 0);


        wall5.move(-15, 10, -15);


        rootNode.attachChild(wall5);





        Box wallCoverb = new Box(Vector3f.ZERO, 60, 20, 0);


        Geometry wallcover1 = new Geometry(“Wall Cover Body 1”, wallCoverb);


        wallcover1.setMaterial(meshMat);





        wallcover1.move(45, 10, 0);


        rootNode.attachChild(wallcover1);


        RigidBodyControl wallBody1 = new RigidBodyControl(0);


        wallcover1.addControl(wallBody1);


        bulletAppState.getPhysicsSpace().add(wallcover1);








        Geometry wall6 = new Geometry(“Back Wall 1”, wallBox);


        wall6.setMaterial(concrete);


        wall6.rotate(0, 90 
 FastMath.DEG_TO_RAD, 0);


        wall6.move(90 + 15, 10, -15);


        rootNode.attachChild(wall6);





        Geometry wall7 = new Geometry(“Back Wall 2”, wallBox);


        wall7.setMaterial(concrete);


        wall7.rotate(0, 90  FastMath.DEG_TO_RAD, 0);


        wall7.move(90 + 15, 10, -45);


        rootNode.attachChild(wall7);





        Geometry wall8 = new Geometry(“Back Wall 3”, wallBox);


        wall8.setMaterial(concrete);


        wall8.rotate(0, 90 
 FastMath.DEG_TO_RAD, 0);


        wall8.move(90 + 15, 10, -45 - 30);


        rootNode.attachChild(wall8);





        Geometry wall9 = new Geometry(“Back Wall 4”, wallBox);


        wall9.setMaterial(concrete);


        wall9.rotate(0, 90  FastMath.DEG_TO_RAD, 0);


        wall9.move(90 + 15, 10, -45 - 60);


        rootNode.attachChild(wall9);





        Geometry wall10 = new Geometry(“Side Wall 1”, wallBox);


        wall10.setMaterial(concrete);


        wall10.move(wall1.getLocalTranslation().x, 10, -45 - 60 - 15);


        rootNode.attachChild(wall10);





        Geometry wall14 = new Geometry(“Wall 14”, wallBox);


        wall14.setMaterial(concrete);


        wall14.rotate(0, 90 
 FastMath.DEG_TO_RAD, 0);


        wall14.move(wall10.getLocalTranslation().x - 15, 10, -45 - 60);


        rootNode.attachChild(wall14);





        Geometry wall15 = new Geometry(“Wall 15”, wallBox);


        wall15.setMaterial(concrete);


        wall15.move(wall14.getLocalTranslation().x - 15, 10, -45 - 30 - 15);


        rootNode.attachChild(wall15);





        Geometry wall16 = new Geometry(“Wall 16”, wallBox);


        wall16.setMaterial(concrete);


        wall16.rotate(0, 90  FastMath.DEG_TO_RAD, 0);


        wall16.move(wall15.getLocalTranslation().x - 15, 10, -45 - 30);


        rootNode.attachChild(wall16);





        Geometry wall17 = new Geometry(“Wall 17”, wallBox);


        wall17.setMaterial(concrete);


        wall17.rotate(0, 90 
 FastMath.DEG_TO_RAD, 0);


        wall17.move(wall16.getLocalTranslation().x, 10, -45);


        rootNode.attachChild(wall17);





        Geometry wall18 = new Geometry(“wall 18”, wallBox);


        wall18.setMaterial(concrete);


        wall18.move(wall17.getLocalTranslation().x + 15, 10, -30);


        rootNode.attachChild(wall18);


        //Mini Room Walls





        Geometry minWall1 = new Geometry(“Mini Room Wall 1”, wallBox);


        minWall1.setMaterial(concrete);


        minWall1.rotate(0, 90  FastMath.DEG_TO_RAD, 0);


        minWall1.move(wall2.getLocalTranslation().x - 15, 10, -45 - 60 - 30);


        rootNode.attachChild(minWall1);





        Geometry minWall2 = new Geometry(“Mini Room Wall 2”, wallBox);


        minWall2.setMaterial(concrete);


        minWall2.move(wall2.getLocalTranslation().x, 10, -45 - 90 - 15);


        rootNode.attachChild(minWall2);





        Geometry minWall3 = new Geometry(“Mini Room Wall 3”, wallBox);


        minWall3.setMaterial(concrete);


        minWall3.rotate(0, 90 
 FastMath.DEG_TO_RAD, 0);


        minWall3.move(wall2.getLocalTranslation().x + 15, 10, -45 - 90);


        rootNode.attachChild(minWall3);





        Box minFloorBox = new Box(Vector3f.ZERO, 15, 0, 15);


        Geometry minFloor1 = new Geometry(“Mini Room Floor 1”, minFloorBox);


        minFloor1.setMaterial(concreteFaceless);


        minFloor1.move(minWall2.getLocalTranslation().x, 0, minWall2.getLocalTranslation().z + 15);


        rootNode.attachChild(minFloor1);





        Geometry wall12 = new Geometry(“Side Wall 3”, wallBox);


        wall12.setMaterial(concrete);


        wall12.move(wall3.getLocalTranslation().x, 10, -45 - 60 - 15);


        rootNode.attachChild(wall12);





        Geometry wall13 = new Geometry(“Wall 13”, wallBox);


        wall13.setMaterial(concrete);


        wall13.move(wall12.getLocalTranslation().x + 30, 10, -45 - 75);


        rootNode.attachChild(wall13);





        mp5 = assetManager.loadModel(“Guns/mp5.obj”);


        mp5.setLocalScale(0.05f);


        ak = assetManager.loadModel(“Guns/HUD.obj”);


        ak.setLocalScale(4f);


        //aug = assetManager.loadModel(“Guns/aug.obj”);


        // aug.setLocalScale(0.05f);


//        m4a1 = assetManager.loadModel(“Guns/m4a1.obj”);


        //  m4a1.setLocalScale(0.05f);





        Material akTex = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        //  akTex.setTexture(“ColorMap”, assetManager.loadTexture(“Guns/akTex.png”));


        //  ak.setMaterial(akTex);


        ak.move(0, 3, 0);


        ak.setLocalScale(1);


        //rootNode.attachChild(ak);








        //Gun m16


        camNode = new Node(“Camera”);


        rootNode.attachChild(camNode);


        m16 = assetManager.loadModel(“Guns/m16.obj”);


        m16.setLocalScale(0.06f);


        Material m16tex = assetManager.loadMaterial(“Materials/m16/Flipm16.j3m”);


        m16.setMaterial(m16tex);


        m16.rotate(0, 95  FastMath.DEG_TO_RAD, 0);


        m16_x = -0.8f;


        m16_y = -0.8f;


        m16_z = 3;


        m16.setLocalTranslation(m16_x, m16_y, m16_z);


        camNode.attachChild(m16);


        capsule1 = new CapsuleCollisionShape(5, 5, 1);


        capsule2 = new CapsuleCollisionShape(5, 2, 1);





        BoxCollisionShape charShape = new BoxCollisionShape(new Vector3f(5, 10, 5));





        player = new CharacterControl(charShape, 0.05f); //0.05f default for step size


        player.setJumpSpeed(20);


        player.setFallSpeed(30);


        player.setGravity(30);


        player.setPhysicsLocation(new Vector3f(-10, 10, -10));


        bulletAppState.getPhysicsSpace().setGravity(new Vector3f(0f, -1f, 0f));


        bulletAppState.getPhysicsSpace().add(player);


        Box rupeeBox = new Box(Vector3f.ZERO, 0.25f, 0.5f, 0);





        rupee = new Geometry(“Red Rupee”, rupeeBox);


        rupee.setQueueBucket(Bucket.Transparent);


        rupeeSkin = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        rupeeSkin.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);


        rupee.setMaterial(rupeeSkin);


        rupee.move(0, 12, 0);


        rootNode.attachChild(rupee);





        Box enemyBox = new Box(Vector3f.ZERO, 2, 4, 0);


        solMat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        solMat.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/soldier/0.png”));


        solMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);


        BoxCollisionShape asdf = new BoxCollisionShape(new Vector3f(2, 4, 1));


        Material spec = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        spec.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/soldier/spec.png”));


        spec.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);


        for (int a = 0; a < soldiers.length; a++) {


            soldiers[a] = new Geometry(“Enemy Soldier #” + a, enemyBox);


            soldiers[a].setQueueBucket(Bucket.Transparent);


            soldiers[a].setMaterial(solMat);


            rootNode.attachChild(soldiers[a]);


            soldierBody[a] = new RigidBodyControl(asdf, 170);


            //  soldierBody[a].setGravity(new Vector3f(0, -1, 0));


            soldiers[a].addControl(soldierBody[a]);


            soldierBody[a].setPhysicsLocation(new Vector3f(-10, 4, -60));


            bulletAppState.getPhysicsSpace().add(soldierBody[a]);


            soldiersHealth[a] = 250;


        }


        soldiers[0].setMaterial(spec);


        Box bulletBox = new Box(Vector3f.ZERO, 0.5f, 0.5f, 0);


        bullet = new Geometry(“Bullet”, bulletBox);


        bullet.setQueueBucket(Bucket.Transparent);


        Material bulletMat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);


        bulletMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);


        bulletMat.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/bullethole.png”));


        bullet.setMaterial(bulletMat);


        rootNode.attachChild(bullet);





        bulletAppState.getPhysicsSpace().enableDebug(assetManager);


    }


    Geometry bullet;





    public void gunMove() {


        //Default values x,y,z


        //m16_x = -0.8f;


        // m16_y = -0.8f;


        // m16_z = 3;


        if (gunUpdater <= 40) {


            gunUpdater++;


        } else {


            gunUpdater = 0;


        }


        if (gunUpdater % 4 == 0) {


            //Left and right


            if (goright && m16_x <= -0.7f) {


                m16_x += 0.001;


            }


            if (goright && m16_x >= -0.7f) {


                goright = false;


                goleft = true;


            }


            if (goleft) {


                m16_x -= 0.001;


            }


            if (m16_x <= -0.8f && goleft) {


                goright = true;


                goleft = false;


            }


        }


        if (gunUpdater % 2 == 0) {


            //Up and down


            if (goup && m16_y <= -0.7f) {


                m16_y += 0.001;


            }


            if (goup && m16_y >= -0.7f) {


                goup = false;


                godown = true;


            }


            if (godown) {


                m16_y -= 0.001;


            }


            if (m16_y <= -0.8f && godown) {


                goup = true;


                godown = false;


            }


        }


    }





    public void strafe() {


        if (!cantStrafe) {


            if (gunUpdater2 <= 40) {


                gunUpdater2++;


            } else {


                gunUpdater2 = 0;


            }


            if (gunUpdater2 % 4 == 0) {


                //Left and right


                if (goright && m16_x <= -0.7f) {


                    m16_x += 0.001;


                }


                if (goright && m16_x >= -0.7f) {


                    goright = false;


                    goleft = true;


                }


                if (goleft) {


                    m16_x -= 0.001;


                }


                if (m16_x <= -0.8f && goleft) {


                    goright = true;


                    goleft = false;


                }


            }


        }


    }


    Vector3f angle = new Vector3f();


    int rupf = 1;


    int synchr = 0;


    int enemyFrames = 0;





    @Override


    public void simpleUpdate(float tpf) {


        Vector3f camDirection = cam.getDirection().clone().multLocal(0.4f); //0.6f


        for (int a = 0; a < soldiers.length; a++) {


            System.out.println(soldierBody[a].getPhysicsLocation().distance(cam.getLocation()));


            if (soldierBody[a].getPhysicsLocation().distance(cam.getLocation()) < 150) {


                soldierBody[a].setLinearVelocity(new Vector3f(camDirection.x, 0, camDirection.z).negate().mult((float) (Math.random() 
 45 + 30)));


            } else {


                soldierBody[a].setLinearVelocity(Vector3f.ZERO);


            }


            soldierBody[a].setPhysicsRotation(cam.getRotation());


            if (a != 0) {


                soldiers[a].setMaterial(solMat);


            }


            soldiers[a].setLocalTranslation(soldierBody[a].getPhysicsLocation());


        }


        //Enemy Code


        if (synchr % 30 == 0) {


            if (enemyFrames < 3) {


                enemyFrames++;


            } else {


                enemyFrames = 0;


            }


        }


        solMat.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/soldier/” + enemyFrames + “.png”));


        m16.setLocalTranslation(m16_x + recx, m16_y + recy, m16_z + recoil_z);


        updateDelay++;


        Vector3f camLeft = cam.getLeft().clone().multLocal(0.2f);


        camDirection.y = 0;


        camLeft.y = 0;


        walkDirection.set(0, 0, 0);


        if (left) {


            strafe();


            walkDirection.addLocal(camLeft);


        }


        if (left && up || left && down || right && up || right & down || up && right && left || down && left && right) {


            cantStrafe = true;


        } else {


            cantStrafe = false;


        }


        if (right) {


            strafe();


            walkDirection.addLocal(camLeft.negate());


        }


        if (up) {


            gunMove();


            walkDirection.addLocal(camDirection);


        }


        if (down) {


            gunMove();


            walkDirection.addLocal(camDirection.negate());


        }


        if (ammo != 1) {


            ammoText.setText(Float.toString(ammo) + “/” + Float.toString(totalAmmo));


        }


        if (imReloading) {


            //-0.8f default value for gun’s Y


            if (m16_y > -5) {


                m16_y -= 0.04f;


            } else {


                m16_y = -5;


            }


            if (m16_y <= -5) {


                audioRenderer.playSource(reloadSFX);


                reloadTimer–;


                if (reloadTimer <= 0) {


                    if (totalAmmo >= 1) {


                        totalAmmo -= (30 - ammo);


                    }


                    ammo += (30 - ammo); // 25/90


                    imReloading = false;


                    reloadTimer = 250;


                    sendGunUp = true;


                }


            }


        }


        if (ammo > 1 && sendGunUp) {


            if (m16_y < -0.8f) {


                m16_y += 0.04;


            } else {


                m16_y = -0.8f;


            &nb