Character falling into endless void through terrain

@javagame said: Y si cada casa esta sobre el terreno, no necesitas añadir un "suelo" cada vez.

This is what the wireframe shows with your code:

Also: the character falls into the void again without a plane shape

refer to the helloCollision tutorial And if that works, it should, then you should be able ot go back to BetterCharacterControl if you want

I tried:

[java]
CollisionShape sceneShape =
CollisionShapeFactory.createMeshShape((Node) sceneModel);
landscape = new RigidBodyControl(sceneShape, 0);
sceneModel.addControl(landscape);
[/java]

But still falls into void

@DualHunter said: This is what the wireframe shows with your code:

Also: the character falls into the void again without a plane shape

I have pasted in your code and made several small adjustments, it works for me:

  • Removed plane collision shape from initTerrain()
  • Removed initCasa() [And all calls to this method] because I do not have your house model, and this also removes all other plane collision shapes
  • Changed the gravity from 50 to 10 [Normal gravity on earth is 9.8 newtons, so this should simulate real life, unless Normen decides otherwise]
  • Most importantly, I changed the radius of the jugador from 0.3f to 0.6f [0.6 meters, a little big sure, but I think 0.3 meters was too small and that made it fall through the terrain]
  • And finally, used a different terrain, because I don’t have yours, obviously

If you are still having issues after that then I doubt it is related to your code, and I cannot help you.

[java]private void initJugador() {
jugadorNodo = new Node();
CapsuleCollisionShape personajeShape = new CapsuleCollisionShape(0.6f, 1.8f);
jugador = new CharacterControl(personajeShape, speed);
jugadorNodo.addControl(jugador);
bulletAppState.getPhysicsSpace().add(jugador);
bulletAppState.getPhysicsSpace().addAll(jugadorNodo);
rootNode.attachChild(jugadorNodo);
jugador.warp(new Vector3f(0.0f, 60f, 0.0f));
jugador.setGravity(10f);
// jugador.setGravity(new Vector3f(0f, -80f, 0f));
}[/java]

[java] private void initTerrain() {
Spatial terreno = assetManager.loadModel(“Scenes/newScene.j3o”);
RigidBodyControl terrenoControl = new RigidBodyControl(0f);
terreno.addControl(terrenoControl);
bulletAppState.getPhysicsSpace().add(terrenoControl);
bulletAppState.setDebugEnabled(true);
rootNode.attachChild(terreno);
} [/java]

Still not working for me. Could it be because of my terrain somehow?

@DualHunter said: Still not working for me. Could it be because of my terrain somehow?

Maybe… What is your framerate? did you change the radius? Try increasing the radius even further, what happens when you change it to 3?

@javagame said: Maybe... What is your framerate? did you change the radius? Try increasing the radius even further, what happens when you change it to 3?

Uhmmm… How do I do that? :smiley: :-?

[java]CapsuleCollisionShape personajeShape = new CapsuleCollisionShape(0.6f, 1.8f);[/java]

The first parameter to the CapsuleCollisionShape constructor is the radius of the capsule, here I have it to 0.6f… try changing yours to 3 see if it still falls through.

@javagame said: [java]CapsuleCollisionShape personajeShape = new CapsuleCollisionShape(0.6f, 1.8f);[/java]

The first parameter to the CapsuleCollisionShape constructor is the radius of the capsule, here I have it to 0.6f… try changing yours to 3 see if it still falls through.

Still falling through. Damn, what could it be?

@DualHunter said: Still falling through. Damn, what could it be?

How many frames per second are you getting?

@javagame said: How many frames per second are you getting?

Around 100fps

@DualHunter said: Around 100fps

Idk what your problem is, The code above with the adjustments suggested above works perfectly for me. Sorry.