I cant get this to work for the life of me

Ok so I have been working and moding this tutorial

http://www.jmonkeyengine.com/wiki/doku.php/jme2_-_flag_rush_tutorial_series

And i have skiped a few things like the sky box and the force field becuase I dont need them right now. I am stuck on the lessons 4 and 5 I cant get them to work. I have copied the FlagRushInputHandler.java right out of the tutorial so thats should be no problem, but when I compile it and run it just gives me the output from lesson 3.

Here is my code that I am working on;


package com.jme;
import java.util.HashMap;
import java.util.logging.Logger;

import javax.swing.ImageIcon;

import jmetest.flagrushtut.Lesson3;
import com.jme.app.BaseGame;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.input.ChaseCamera;
import com.jme.input.InputHandler;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.thirdperson.ThirdPersonMouseLook;
import com.jme.light.DirectionalLight;
import com.jme.math.FastMath;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;
import com.jme.scene.state.CullState;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;
import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.TextureManager;
import com.jme.util.Timer;
import com.jmex.terrain.TerrainBlock;
import com.jmex.terrain.util.MidPointHeightMap;
import com.jmex.terrain.util.ProceduralTextureGenerator;

public class Hummer extends BaseGame {
   private TerrainBlock tb;
   protected Timer timer;
   // Our camera object for viewing the scene
   private Camera cam;
   // the root node of the scene graph
   private Node scene;
   private Node player;
    //private ChaseCamera chaser;
    protected InputHandler input;
    private ChaseCamera chaser;
   
   // display attributes for the window. We will keep these values
   // to allow the user to change them
   private int width, height, depth, freq;
 
   private boolean fullscreen;
 
   /**
    * Main entry point of the application
    */
   public static void main(String[] args) {
      Lesson3 app = new Lesson3();
      // We will load our own "fantastic" Flag Rush logo. Yes, I'm an artist.
      app.setConfigShowMode(ConfigShowMode.AlwaysShow,
                                Lesson3.class.getClassLoader()
                                       .getResource("jmetest/data/images/FlagRush.png"));
      app.start();
   }
 
   /**
    * During an update we only look for the escape button and update the timer
    * to get the framerate.
    *
    * @see com.jme.app.SimpleGame#update()
    */
      protected void update(float interpolation) {
           // update the time to get the framerate
           timer.update();
           interpolation = timer.getTimePerFrame();
           //update the keyboard input (move the player around)
           input.update(interpolation);
           //update the chase camera to handle the player moving around.
           chaser.update(interpolation);
       
           // if escape was pressed, we exit
           if (KeyBindingManager.getKeyBindingManager().isValidCommand("exit")) {
               finished = true;
           }
   
           //We don't want the chase camera to go below the world, so always keep
           //it 2 units above the level.
           if(cam.getLocation().y < (tb.getHeight(cam.getLocation())+2)) {
               cam.getLocation().y = tb.getHeight(cam.getLocation()) + 2;
               cam.update();
           }
   
           //make sure that if the player left the level we don't crash. When we add collisions,
           //the fence will do its job and keep the player inside.
           float characterMinHeight = tb.getHeight(player
                   .getLocalTranslation())+((BoundingBox)player.getWorldBound()).yExtent;
           if (!Float.isInfinite(characterMinHeight) && !Float.isNaN(characterMinHeight)) {
               player.getLocalTranslation().y = characterMinHeight;
           }
   
           //Because we are changing the scene (moving the skybox and player) we need to update
           //the graph.
           scene.updateGeometricState(interpolation, true);
       }

   
 
   /**
    * draws the scene graph
    *
    * @see com.jme.app.SimpleGame#render()
    */
      protected void render(float interpolation) {
           // Clear the screen
           display.getRenderer().clearBuffers();
           display.getRenderer().draw(scene);
           chaser.update(interpolation);
       }
   

 
   /**
    * initializes the display and camera.
    *
    * @see com.jme.app.SimpleGame#initSystem()
    */
   protected void initSystem() {
      // store the properties information
      width = settings.getWidth();
      height = settings.getHeight();
      depth = settings.getDepth();
      freq = settings.getFrequency();
      fullscreen = settings.isFullscreen();
 
      try {
         display = DisplaySystem.getDisplaySystem(settings.getRenderer());
         display.createWindow(width, height, depth, freq, fullscreen);
 
         cam = display.getRenderer().createCamera(width, height);
      } catch (JmeException e) {
         e.printStackTrace();
         System.exit(1);
      }
 
      // set the background to black
      display.getRenderer().setBackgroundColor(ColorRGBA.black);
 
      // initialize the camera
      cam.setFrustumPerspective(45.0f, (float) width / (float) height, 1,
            1000);
      Vector3f loc = new Vector3f(500.0f, 150.0f, 500.0f);
      Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
      Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
      Vector3f dir = new Vector3f(0.0f, 0.0f, -1.0f);
      // Move our camera to a correct place and orientation.
      cam.setFrame(loc, left, up, dir);
      /** Signal that we've changed our camera's location/frustum. */
      cam.update();
 
      /** Get a high resolution timer for FPS updates. */
      timer = Timer.getTimer();
 
      display.getRenderer().setCamera(cam);
 
      KeyBindingManager.getKeyBindingManager().set("exit",
            KeyInput.KEY_ESCAPE);
   }
 
   /**
    * initializes the scene
    *
    * @see com.jme.app.SimpleGame#initGame()
    */
   protected void initGame() {
      display.setTitle("Humvee Adventure");
      scene = new Node("Scene graph node");
      buildTerrain();
      buildPlayer();
      buildChaseCamera();
      
      scene.attachChild(tb);
      input = new FlagRushHandler(player, settings.getRenderer());
       buildLighting();
 
      // update the scene graph for rendering
      scene.updateGeometricState(0.0f, true);
      scene.updateRenderState();
      
      ZBufferState buf = display.getRenderer().createZBufferState();
      buf.setEnabled(true);
      buf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
      scene.setRenderState(buf);
      
      //cull states
      CullState cs = display.getRenderer().createCullState();
      cs.setCullFace(CullState.Face.Back);
      scene.setRenderState(cs);
   }
 
   /**
    * creates a light for the terrain.
    */
   private void buildLighting() {
      /** Set up a basic, default light. */
       DirectionalLight light = new DirectionalLight();
       light.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
       light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
       light.setDirection(new Vector3f(1,-1,0));
       light.setEnabled(true);
 
         /** Attach the light to a lightState and the lightState to rootNode. */
       LightState lightState = display.getRenderer().createLightState();
       lightState.setEnabled(true);
       lightState.attach(light);
       scene.setRenderState(lightState);
   }
 
   /**
    * build the height map and terrain block.
    */
   private void buildTerrain() {
 
 
      // Generate a random terrain data
      MidPointHeightMap heightMap = new MidPointHeightMap(64, 1f);
      // Scale the data
      Vector3f terrainScale = new Vector3f(20, 0.5f, 20);
      // create a terrainblock
      tb = new TerrainBlock("Terrain", heightMap.getSize(), terrainScale,
            heightMap.getHeightMap(), new Vector3f(0, 0, 0));
 
      tb.setModelBound(new BoundingBox());
      tb.updateModelBound();
 
      // generate a terrain texture with 3 textures
      ProceduralTextureGenerator pt = new ProceduralTextureGenerator(
            heightMap);
      pt.addTexture(new ImageIcon(Lesson3.class.getClassLoader()
            .getResource("jmetest/data/texture/grassb.png")), -128, 0, 128);
      pt.addTexture(new ImageIcon(Lesson3.class.getClassLoader()
            .getResource("jmetest/data/texture/dirt.jpg")), 0, 128, 255);
      pt.addTexture(new ImageIcon(Lesson3.class.getClassLoader()
            .getResource("jmetest/data/texture/highest.jpg")), 128, 255,
            384);
      pt.createTexture(32);
 
      // assign the texture to the terrain
      TextureState ts = display.getRenderer().createTextureState();
      ts.setEnabled(true);
      Texture t1 = TextureManager.loadTexture(pt.getImageIcon().getImage(),
            Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear, true);
      ts.setTexture(t1, 0);
 
      tb.setRenderState(ts);
   }
   
   private void buildPlayer() {
        //box stand in
        Box b = new Box("box", new Vector3f(), 0.35f,0.25f,0.5f);
        b.setModelBound(new BoundingBox());
        b.updateModelBound();
 
        player = new Node("Player Node");
        player.setLocalTranslation(new Vector3f(100,0, 100));
        scene.attachChild(player);
        player.attachChild(b);
        player.updateWorldBound();
       
        float characterMinHeight = tb.getHeight(player
                .getLocalTranslation())+((BoundingBox)player.getWorldBound()).yExtent;
if (!Float.isInfinite(characterMinHeight) && !Float.isNaN(characterMinHeight)) {
            player.getLocalTranslation().y = characterMinHeight;}

}
   private void buildChaseCamera() {
        Vector3f targetOffset = new Vector3f();
        targetOffset.y = ((BoundingBox) player.getWorldBound()).yExtent * 1.5f;
        HashMap<String, Object> props = new HashMap<String, Object>();
        props.put(ThirdPersonMouseLook.PROP_MAXROLLOUT, "6");
        props.put(ThirdPersonMouseLook.PROP_MINROLLOUT, "3");
        props.put(ChaseCamera.PROP_TARGETOFFSET, targetOffset);
        props.put(ThirdPersonMouseLook.PROP_MAXASCENT, ""+45 * FastMath.DEG_TO_RAD);
        props.put(ChaseCamera.PROP_INITIALSPHERECOORDS, new Vector3f(5, 0, 30 * FastMath.DEG_TO_RAD));
        props.put(ChaseCamera.PROP_TARGETOFFSET, targetOffset);
        chaser = new ChaseCamera(cam, player, props);
        chaser.setMaxDistance(8);
        chaser.setMinDistance(2);
       
}
   
   /**
    * will be called if the resolution changes
    *
    * @see com.jme.app.SimpleGame#reinit()
    */
   protected void reinit() {
      display.recreateWindow(width, height, depth, freq, fullscreen);
   }
 
   /**
    * clean up the textures.
    *
    * @see com.jme.app.SimpleGame#cleanup()
    */
   protected void cleanup() {
 
   }
   


What am i doing wrong with this?
Thanks

   public static void main(String[] args) {
      Lesson3 app = new Lesson3();
      // We will load our own "fantastic" Flag Rush logo. Yes, I'm an artist.
      app.setConfigShowMode(ConfigShowMode.AlwaysShow,
                                Lesson3.class.getClassLoader()
                                       .getResource("jmetest/data/images/FlagRush.png"));
      app.start();
   }



You start the wrong class in your main!!! Replace Lesson3 with Hummer...

Ha Ha thanks I missed that, I have been rewriting this whole thing serveral times just today and its getting a little dounting. :smiley:

Hi its me agin and yes I got stuck once more. Ok so I have gotten pertty much all but the Flag Rush handeler to work.


package com.jme;
import com.jme.input.InputHandler;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;


public class FlagRushHandler extends InputHandler {
    //the vehicle we are going to control
    private Vehicle vehicle;
    //the default action
    private DriftAction drift;
   
    public void update(float time) {
        if ( !isEnabled() ) return;

        super.update(time);
        //we always want to allow friction to control the drift
        drift.performAction(event);
        vehicle.update(time);
    }
   
    /**
     * Supply the node to control and the api that will handle input creation.
     * @param vehicle the node we wish to move
     * @param api the library that will handle creation of the input.
     */
    public FlagRushHandler(Vehicle vehicle, String api) {
        this.vehicle = vehicle;
        setKeyBindings(api);
        setActions(vehicle);

    }

    /**
     * creates the keyboard object, allowing us to obtain the values of a keyboard as keys are
     * pressed. It then sets the actions to be triggered based on if certain keys are pressed (WSAD).
     * @param api the library that will handle creation of the input.
     */
    private void setKeyBindings(String api) {
        KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager();

        keyboard.set("forward", KeyInput.KEY_W);
        keyboard.set("backward", KeyInput.KEY_S);
        keyboard.set("turnRight", KeyInput.KEY_D);
        keyboard.set("turnLeft", KeyInput.KEY_A);
    }

    /**
     * assigns action classes to triggers. These actions handle moving the node forward, backward and
     * rotating it. It also creates an action for drifting that is not assigned to key trigger, this
     * action will occur each frame.
     * @param node the node to control.
     */
    private void setActions(Vehicle node) {
        ForwardAndBackwardAction forward = new ForwardAndBackwardAction(node, ForwardAndBackwardAction.FORWARD);
        addAction(forward, "forward", true);
        ForwardAndBackwardAction backward = new ForwardAndBackwardAction(node, ForwardAndBackwardAction.BACKWARD);
        addAction(backward, "backward", true);
        VehicleRotateAction rotateLeft = new VehicleRotateAction(node, VehicleRotateAction.LEFT);
        addAction(rotateLeft, "turnLeft", true);
        VehicleRotateAction rotateRight = new VehicleRotateAction(node, VehicleRotateAction.RIGHT);
        addAction(rotateRight, "turnRight", true);
       
        //not triggered by keyboard
        drift = new DriftAction(node);
    }
}



Yeah its all there from the lessons and Every other .java file is also there the VehicalRotation ect, but for some reason at the end of the code the

 private void setActions(Vehicle node) {
        ForwardAndBackwardAction forward = new ForwardAndBackwardAction(node, ForwardAndBackwardAction.FORWARD);
        addAction(forward, "forward", true);
        ForwardAndBackwardAction backward = new ForwardAndBackwardAction(node, ForwardAndBackwardAction.BACKWARD);
        addAction(backward, "backward", true);
        VehicleRotateAction rotateLeft = new VehicleRotateAction(node, VehicleRotateAction.LEFT);
        addAction(rotateLeft, "turnLeft", true);
        VehicleRotateAction rotateRight = new VehicleRotateAction(node, VehicleRotateAction.RIGHT);
        addAction(rotateRight, "turnRight", true);
       
        //not triggered by keyboard
        drift = new DriftAction(node);
    }


keeps sayig that "Description Resource Path Location Type
The constructor ForwardAndBackwardAction(Vehicle, int) is undefined FlagRushHandler.java /Hummer/src/com/jme line 55 Java Problem
"

what is wrong with the code I tried to change some of it it just keep giveing me another problem in the other parts of the code.
I have attached all of my code so far
Thanks

Well, if you did not write a class called ForwardAndBackwardAction with a constructor that takes a Node and an int you cannot instantiate an object from it :slight_smile: If you did, is it in the same package as the other files?

Like this right, this the class that i have in my package.

public class ForwardAndBackwardAction extends KeyInputAction {
    public static final int FORWARD = 0;
    public static final int BACKWARD = 1;
    //the node to manipulate
    private Vehicle node;
    private int direction;

    /**
     * The vehicle to accelerate is supplied during construction.
     * @param node the vehicle to speed up.
     * @param direction Constant either FORWARD or BACKWARD
     */
    public ForwardAndBackwardAction(Vehicle node, int direction) {
        this.node = node;
        this.direction = direction;
    }

    /**
     * the action calls the vehicle's accelerate or brake command which adjusts its velocity.
     */
    public void performAction(InputActionEvent evt) {
        if(direction == FORWARD) {
            node.accelerate(evt.getTime());
        } else if(direction == BACKWARD){
            node.brake(evt.getTime());
        }
    }
}

Do you know that you can find the whole tutorial (compilable) in jmetest.flagrushtut.* - package of the svn-repository

Hi, I got it working I had to change a few things but yeah its running

Thanks ttrocha  and normen for all the [glow=brown,2,300]Help[/glow]. :smiley: