[SOLVED] Help with Kart Racing Game

So I am VERY new to JME3, I first got into Game Dev trying out Unity, but I found Java a much easier programming language so I tried JME3, and personally, it is better than Unity :slight_smile:
My project is a kart racing game and I have all the track built, but I need to know some info on creating the input operations in order to actually drive the vehicle. I hope to get some replies from the seemingly very helpful pack of monkeys. Btw I already checkout out the wiki’s input page, but nothing worked…….

3 Likes

What didn’t work? What happens?

There is a racing game linked to the wiki,

https://code.google.com/archive/p/street-rally-3d/source/default/source

Its also linked here,

and I think this is related to it,

and this is how to find them all.

Hit the Wiki link in the nav bar at top of page, enter racing into the search box at top of that page and its all there.

No Idea if its any good.

Might get ideas though.

Hi @Burgame :slight_smile:

myself i did not use vehicles.

edit:
for part:

Btw I already checkout out the wiki’s input page, but nothing worked…….

see below part of my post

But i think every basic information should be here:

https://wiki.jmonkeyengine.org/jme3/advanced/vehicles.html

and there is:

Define the steering actions to be triggered by the key events.

* `vehicle.steer()`
* `vehicle.accelerate()`
* `vehicle.brake()`

so as i see you trully define Control class

vehicle = new VehicleControl(compoundShape, 400);

and add it into yout vehicle Spatial(Node)

vehicleNode.addControl(vehicle);

here is some input example:

public void onAction(String binding, boolean value, float tpf) {
  if (binding.equals("Lefts")) {
      if (value) { steeringValue += .5f; } else { steeringValue += -.5f; }
      vehicle.steer(steeringValue);
  } else if (binding.equals("Rights")) {
      if (value) { steeringValue += -.5f; } else { steeringValue += .5f; }
      vehicle.steer(steeringValue);
  } else if (binding.equals("Ups")) {
      if (value) {
        accelerationValue += accelerationForce;
      } else {
        accelerationValue -= accelerationForce;
      }
      vehicle.accelerate(accelerationValue);
  } else if (binding.equals("Downs")) {
      if (value) { vehicle.brake(brakeForce); } else { vehicle.brake(0f); }
  } else if (binding.equals("Space")) {
      if (value) {
        vehicle.applyImpulse(jumpForce, Vector3f.ZERO);
      }
  } else if (binding.equals("Reset")) {
      if (value) {
        System.out.println("Reset");
        vehicle.setPhysicsLocation(Vector3f.ZERO);
        vehicle.setPhysicsRotation(new Matrix3f());
        vehicle.setLinearVelocity(Vector3f.ZERO);
        vehicle.setAngularVelocity(Vector3f.ZERO);
        vehicle.resetSuspension();
      } else {
    }
  }
}

if you will find something missing on Wiki, it would be best if you report.

Btw I already checkout out the wiki’s input page, but nothing worked…….

if you have JME SDK, then you can create JME Tests example project, where all tests/examples are. You can easly access sourcecode and see. You can run this tests(from this project) and see if it works. It will work so you can check what you do wrong.

For example here is one:

1 Like

Thanks for feedback, I will remove it then.

why u quote it as me while it was his words that i quoted? :sweat_smile:

oops. I see now. Sorry about that.

@Burgame what were you referencing to that did not work from the wiki?

inputs works, nothing changed, so it must still work. Anyway JME Tests works, so its proof it works. Thats why i also link him into JME Tests so he would be able to see it works. (wiki input page is about general inputs)

1 Like

I see, I misunderstood input to mean java methods he wrote.