BetterCharacterControl sinks through the ground

Im setting up a scene where a player falls a short distance to the ground. However when i start the application. The box sinks half way into ground. I read so i made the floor and charactor unit boxes. but that had no effect. Im just trying to understand whats happening here?

public void simpleInitApp() {
/** Set up Physics */
bulletAppState = new BulletAppState();

viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f));


// We load the scene from the zip file and adjust its size.
sceneModel = new Node("scene node");

// We set up collision detection for the scene by creating a
// compound collision shape and a static RigidBodyControl with mass zero.
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) sceneModel);
landscape = new RigidBodyControl(sceneShape, 0);

player = new BetterCharacterControl(.5f, 1f, 1f);
player.setJumpForce(new Vector3f(0, 20, 0));
player.setGravity(new Vector3f(0, -10, 0));

characterNode = new Node("character node");
characterNode.setLocalTranslation(new Vector3f(0, 5, 0));

Geometry b = new Geometry("Player", new Box(1, 1, 1));
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);

ChaseCamera chaseCam = new ChaseCamera(cam, characterNode, inputManager);

// We attach the scene and the player to the rootnode and the physics space,
// to make them appear in the game world.



/** A floor to show that the “shot” can go through several objects. */
protected Geometry makeFloor() {
Box box = new Box(1, 1f, 1);
Geometry floor = new Geometry(“the Floor”, box);
floor.setLocalTranslation(0, -4, 0);
Material mat1 = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat1.setColor(“Color”, ColorRGBA.Gray);
return floor;

Interesting if i increase the radius of BetterCharacterControl the box bounces like a trampoline… which i also don’t understand. but still only bounces after it has sunk into the ground

ok so after reading
im guessing i should not use BetterCharacterControl?

From the documentation you have

The box has a center of 0,0,0 and extends in the out from the center by the given amount in each direction. So, for example, a box with extent of 0.5 would be the unit cube.

So, when you create your box like this:

new Box(1, 1, 1)
(in the creation of the player’s geometry), you have a box with a dimension of 2 for each vertex. So, when you create a bettercharactercontrol with a height of 1 (it’s pretty small and fat guy btw : 1m height, 1m of diameter … and 1kg … ).

So, first i advice you to change the dimension of the box.
Second, i think you should create the bettercharactercontrol with 0.3;1.8;80 (30cm diameter (still fat but ok), 1.8m height, 80kg).

And enable the debug for the physics, so you’ll be able to see the collisions.
You can enable it like this :


Did as you suggested

player = new BetterCharacterControl(.3f, 1.8f, 80f);
Geometry b = new Geometry(“Player”, new Box(.5f, .5f, .5f));
which made perfect sense

but the scene behaved exactly the same . I can’t see any additional output from enabling debug either

the debug doesn’t do any output, except in the view. You should see wires around your meshes, it’s the collision. Then, you’ll be able to see if the pysic part sink into the ground (and it would be a problem) or if it’s only the graphic part. For exemple, i know that you have a difference between the charactercontrol and the bettercharactercontrol : in one of them (i don’t remember exactly) the spatial (=the visual part) is attached to the base, for the other it’s attached to the middle or the top. I really don’t remember which one do what, and this evening i am really tired. I’ll look further into it tomorrow.

btw, if you have a client-server app and the physics only server-side, you’ll not be able to see the wire with the debug part - which make sense, as the client doens’t have physics (except if you have also physic client-side).

I’m having the same problem.

I solved the problem by attaching my character to a node and adjusting the character within the node. Here’s the code:

[java]Spatial playerSpatial = assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);
player = (Node)playerSpatial;
Node playerNode = new Node(); // this is the wrapper node

    /* Load the animation controls, listen to animation events,
 * create an animation channel, and bring the model in its default position.  */
    control = player.getControl(AnimControl.class);
    channel = control.createChannel();
    playerControl = new BetterCharacterControl(1.5f, 6f, 1f);
    playerControl.setJumpForce(new Vector3f(0,5f,0));
    playerControl.setGravity(new Vector3f(0,1f,0));
    // Finally we put the player in its starting position and update its state – remember to use setPhysicsLocation() instead of setLocalTranslation() now, since you are dealing with a physical object.
    playerControl.warp(new Vector3f(0,10,10));
    // We need to register all solid objects to the PhysicsSpace!
    rootNode.attachChild(playerNode); // don't forget to add to root.[/java]

If you increase the mass and height of your BetterCharacterControl, your character will stop bouncing. I’m not sure why increasing the height affected this, but it did. For example:

BetterCharacterControl(.5f, 1f, 1f);[/java]

to something like:

[java] BetterCharacterControl(1.5f, 6f, 4f);[/java]

(The width may be fine at .5f, but you will need to experiment with it yourself.)

I’d expect something only 1 kg to be pretty bouncy.

If you imagine something that is a full 1 meter wide (0.5 radius) and 1 meter tall that only weighs 1 kg… that reminds me of a giant air-filled bouncy ball.

If this is supposed to be a person then you could try setting them to person-sized numbers. Maybe (0.2, 1.8, 80)

I’ve never used BetterCharacterControl but I usually expect a physics engine to behave a certain way in light of the parameters givens. It could be a bad assumption.

Edit: note oto may be a bit wider/taller maybe.

You just need to lower your root bone and i’m guessing the root bone on your model is above the feet. First make sure your skeleton’s feet just just touch the floor grid . Then tab into edit mode and add a new bone have zero rotation making sure its bottom tip has zero translation . Select the root bone then this bone in blender then hit ctrl +p to parent your previous root bone to the new root bone.
Anything below the rootbone in blender will fall thru the floor in jme