This is a copy of another post I made, I think, in the wrong section. So I’m really new to jME and I was trying to make a character walk on the terrain I made. The thing is I’m following a tutorial on YouTube on how to make this but even after writing the code exactly as the video shows, I’m not getting the same results. Some help would be appreciated. Thank you. I don’t know if I can post the link but here it is: - YouTube
And here’s the code:
[java]
public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
app.start();
}
private BulletAppState bulletAppState;
private BetterCharacterControl jugador;
private Node jugadorNodo;
@Override
public void simpleInitApp() {
// Se ajusta la velocidad de la cámara
flyCam.setMoveSpeed(50f);
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
// Se crea el mapa
initTerrain();
initLight();
// Se crea el jugador/héroe
initJugador();
}
private void initTerrain() {
Spatial terreno = assetManager.loadModel(“Scenes/primerMapa.j3o”);
RigidBodyControl terrenoControl = new RigidBodyControl(0f);
terreno.addControl(terrenoControl);
bulletAppState.getPhysicsSpace().add(terrenoControl);
rootNode.attachChild(terreno);
}
private void initLight() {
AmbientLight ambient = new AmbientLight();
ambient.setColor(ColorRGBA.White);
rootNode.addLight(ambient);
}
private void initJugador() {
jugadorNodo = new Node(“Jugador”);
jugador = new BetterCharacterControl(0.3f, 1.8f, 70f);
jugadorNodo.addControl(jugador);
bulletAppState.getPhysicsSpace().add(jugador);
rootNode.attachChild(jugadorNodo);
jugador.warp(new Vector3f(0.0f, 20.0f, 0.0f));
}
@Override
public void simpleUpdate(float tpf) {
cam.setLocation(jugadorNodo.getLocalTranslation().add(new Vector3f(0.0f, 1.8f, 0.0f)));
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
[/java]