Physics on TerrainQuad

I’m generating terrain generally like in TerrainFractalGridTest, however, I want collisions.

It’s working however in some angles with the terrain the character falls bellow the terrain into the endless void.

What do?

Terrain collisions:


if (usePhysics) {

terrain.addListener(new TerrainGridListener() {

public void gridMoved(Vector3f newCenter) {


public Material tileLoaded(Material material, Vector3f cell) {

return material;


public void tileAttached(Vector3f cell, TerrainQuad quad) {

HeightfieldCollisionShape quadShape = new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale());

quad.addControl(new RigidBodyControl(quadShape, 0));



public void tileDetached(Vector3f cell, TerrainQuad quad) {









// Add a physics character to the world

CapsuleCollisionShape cap = new CapsuleCollisionShape(0.5f, 3f);

control = new CharacterControl(cap, .1f);


control.setPhysicsLocation(new Vector3f(0, 1, 0));

character = new Node(“character node”);

Spatial model = app.getAssetManager().loadModel(“Models/man.j3o”);

//make model coincide with collision box

model.setLocalTranslation(0.20f, -2.0f, -0.8f);








Play with the stepHeight of the character and make sure you do ot push it into the terrain with the walkdirection.

I’m not sure what you mean, what class has that method?

Is that exemplified on any of the tests or somewhere else?

Sometimes when the character is falling a big distance into a slope, he enters the terrain and stays partially bellow the terrain, will playing with the stepHeight fix that as well?

My first impression what that somehow the collision shape (or whatever the correct name is) for the terrain is too thin, is that possible?

Sorry for my noobishness.


I’m not sure if a step height is built in.

You will have to do that for your character: checking a step height.

Look at your current spot and get its height. Look at the spot you are moving to this frame and get the height there. If it is beyond a certain amount, don’t move forward.


ya what normen said :slight_smile:

I don’t use physics so I’m just guessing.