Hi,
I’m a newbie at JMonkey and I need a help with a first code. I’m running the HelloColision example and i tried to import a mesh and include into the scene. I don’t have any trouble importing the mesh but when I run the code, the character keeps falling down the scenario. There’s something else to do?
Follow the character code:
private Node jogador;
private CharacterControl player;
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
player = new CharacterControl(capsuleShape, 0.05f);
player.setJumpSpeed(20);
player.setFallSpeed(30);
player.setGravity(30);
player.setPhysicsLocation(new Vector3f(0, 10, 0));
jogador = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);
jogador.addControl(player);
bulletAppState.getPhysicsSpace().add(jogador);
rootNode.attachChild(jogador);
bulletAppState.getPhysicsSpace().add(jogador);
you add this twice:
[java]bulletAppState.getPhysicsSpace().add(jogador);[/java]
not sure if this causes errors, and where is the code you use for the “mesh”? also do:
[java]bulletAppState.getPhysicsSpace().enableDebug(assetManager)[/java]
to see the collision shapes
I’m using the mesh that came along with the JM3:
jogador = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);
The error is when I run the code without the mesh, it works fine, the camera stops and I can move freely through the scene. But when I try to add the specific mesh, it keeps falling…
Please do the tutorials from the start, copy-pasting example code won’t give you a game. Adding the model to a Node and translating it up should not be an issue at all after you did them.