BetterCharacterControl Bouncing Problem

Hi everybody,
I create a floor:
[java]
private Geometry createFloor() {
Box box = new Box(5, 2f, 5);
Geometry floor = new Geometry(“Floor”, box);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, ColorRGBA.Gray);
floor.setMaterial(mat);
return floor;
}
[/java]
simpleInit:
[java]
floor = createFloor();
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape(floor);
landscape = new RigidBodyControl( sceneShape,0);
floor.addControl(landscape);
rootNode.attachChild(floor);
landscape.setPhysicsLocation(new Vector3f(0,-4,0));
bulletAppState.getPhysicsSpace().add(landscape);
[/java]
next i create a player:
[java]
character = new Node();
player = new BetterCharacterControl(1f,1f, 0.01f);
character.addControl(player);
rootNode.attachChild(character);
bulletAppState.getPhysicsSpace().add(character);
player.warp(new Vector3f(0,7,0));
[/java]
All i see is the character going up and down … seems like he is not loosing his velocity.

If i use the “common” CharacterControl, it works but if i move it via
[java]
walkDirection.set(0, 0, 0);
if(left){walkDirection.addLocal(speedtpf, 0, 0);}
if(right){walkDirection.addLocal(-speed
tpf, 0, 0);}
if(forward){walkDirection.addLocal(0, 0, speedtpf);}
if(backward){walkDirection.addLocal(0, 0, -speed
tpf);}
player.setWalkDirection(walkDirection);
[/java]
it clips through the floor.
I’am already really frustrated by this topic and i didn’t find a good solution on the net.
Do you have any idea? Help is really appreciated

2 Likes

What is the third parameter for bettercharacter controll? Mass? cause this is way to low then. Try with a more human value like 80

Tried it, still the same problem. I also set the restitution to 0 and changed the MotionThreshold (). Tried different sizes for the floor.

Try to set a height > to radius in the BetterCharacterControl…i believe i’ve had a similar problem with that by the past.

4 Likes

You Sir, are a genius :slight_smile: Thank you very much! :))))

@EMPJ said: You Sir, are a genius :) Thank you very much! :))))

We see this a lot, actually. I don’t know if there is some example people pull from or what… but:
new BetterCharacterControl(1f,1f, 0.01f);

…always makes me chuckle a little trying to imagine this guy that’s 1 meter tall but can’t fit through doors because he’s two meters wide in all directions. He’d have to roll through doorways on his side. heheh.

1 Like