Character falling through terrain

I’m having trouble with the character falling through terrain when standing on the higher parts of the terrain or trying to climb larger hills. I’ve tried it with multiple heightmaps and it keeps happening. Is this a limitation of the engine or am I doing something wrong? Using a mesh for the terrain and a collisionshape based on that mesh is giving me the same problem.

[java]public class Main extends SimpleApplication implements ActionListener{

private CharacterControl player;

private Vector3f walkDirection = new Vector3f();

private TerrainQuad terrain;

private boolean left = false, right = false, up = false, down = false;

public static void main(String[] args) {

Main app = new Main();




public void simpleInitApp() {

BulletAppState physicsState = new BulletAppState();



DirectionalLight sun = new DirectionalLight();

sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));


Texture ter_tex = assetManager.loadTexture(“Textures/hmp.png”);

AbstractHeightMap heightmap = new ImageBasedHeightMap(ImageToAwt.convert(ter_tex.getImage(), false, true, 0));


terrain = new TerrainQuad(“terrain”, 65, 513, heightmap.getHeightMap());

Material ter_mat = new Material(assetManager,“Common/MatDefs/Misc/Unshaded.j3md”);

Texture ter_color = assetManager.loadTexture(“Textures/Fire02.png”);

ter_mat.setTexture(“ColorMap”, ter_color);


terrain.setLocalTranslation(30, -240f, 0);


CollisionShape terrain_c = new HeightfieldCollisionShape(terrain.getHeightMap());

terrain.addControl(new RigidBodyControl(terrain_c, 0));

CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(4f,9f, 1);

player = new CharacterControl(capsuleShape, 1f);






inputManager.addMapping(“Left”, new KeyTrigger(KeyInput.KEY_A));

inputManager.addMapping(“Right”, new KeyTrigger(KeyInput.KEY_D));

inputManager.addMapping(“Up”, new KeyTrigger(KeyInput.KEY_W));

inputManager.addMapping(“Down”, new KeyTrigger(KeyInput.KEY_S));

inputManager.addMapping(“Jump”, new KeyTrigger(KeyInput.KEY_SPACE));

inputManager.addListener(this, “Left”);

inputManager.addListener(this, “Right”);

inputManager.addListener(this, “Up”);

inputManager.addListener(this, “Down”);

inputManager.addListener(this, “Jump”);


public void onAction(String binding, boolean value, float tpf) {

if (binding.equals(“Left”)) {

if (value) { left = true; } else { left = false; }

} else if (binding.equals(“Right”)) {

if (value) { right = true; } else { right = false; }

} else if (binding.equals(“Up”)) {

if (value) { up = true; } else { up = false; }

} else if (binding.equals(“Down”)) {

if (value) { down = true; } else { down = false; }

} else if (binding.equals(“Jump”)) {





public void simpleUpdate(float tpf) {

Vector3f camDir = cam.getDirection().clone().multLocal(0.6f);

Vector3f camLeft = cam.getLeft().clone().multLocal(0.4f);

walkDirection.set(0, 0, 0);

if (left) { walkDirection.addLocal(camLeft); }

if (right) { walkDirection.addLocal(camLeft.negate()); }

if (up) { walkDirection.addLocal(camDir); }

if (down) { walkDirection.addLocal(camDir.negate()); }






Try increasing/decreasing the stepheight of your charactercontrol.

I changed it back and forth with no luck… the slope doesnt seem to be an issue. I made the terrain bigger and it only messes up at the tops of hills mainly. almost like theres an invisible wall on top and it bounces between that and the terrain until it’s pushed through the level

Edit: Actually, it only messes up near the top of the tallest hill now.

It has to do with translating the terrain. The lod calculation doesn’t take translation of the terrain into account. As an effect the terrains LOD is lowered right beneath the character, and this in affects alters the collisionshape it seems. Don’t translate the terrain in x or z direction :stuck_out_tongue: The terrain classes aren’t fully adapted to translations yet I guess.

I think it was the translation, it works now that I moved the player instead of the terrain. Thanks!