jme3 better character control does not collide with scene

Hi I have problem, my character with “BetterCharacterControl” does not collide with my scene, I don’t know why.

private BetterCharacterControl characterPlayer;
private Node player;

private void createCharacter() {
capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
landscape = new RigidBodyControl(sceneShape, 0);
player = (Node) assetManager.loadModel(“Models/Oto.mesh.xml”);
characterPlayer = new BetterCharacterControl(0.3f, 2.5f, 8f);
// characterPlayer.setJumpSpeed(30);
// characterPlayer.setFallSpeed(30);
characterPlayer.setGravity(new Vector3f(0, -9.81f, 0));
characterPlayer.getDuckedFactor();
player.addControl(characterPlayer);
player.setLocalTranslation(new Vector3f(60, 10, -60));
// characterPlayer.setPhysicsLocation(new Vector3f(60, 10, -60));
bulletAppState.getPhysicsSpace().add(landscape);
bulletAppState.getPhysicsSpace().add(characterPlayer);
rootNode.attachChild(player);
}

I was remaking form “CharacterControl” on “BetterCaracterControl” and I can’t find mistake, why it does not collide.

Do you have any opinion, how to do it?
You will help me a lot, thanks.

Hmm.

On first glance this code looks like it should work, although your capsuleShape does nothing at all^^

Did you attach the bulletAppState to the stateManager correctly?

If you did you could test, if the collisionshapes are correctly set by enabling the debug-view:
bulletAppState.setDebugEnabled(true);

Yes I did it attach in to the stateManager correctly.

@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
bulletAppState.setDebugEnabled(true);
stateManager.attach(bulletAppState);
initMaterials();
setupKeys();
createLight();
createSky();
createMap();
createCharacter();
createNPC();
createHitBox();
setupChaseCamera();
initCrossHairs();
setupAnimationController();
setupFilter();
}

Problem is, that
CharacterControl(CollisionShape shape, float stepHeight)
BetterCharacterControl(float radius, float height, float mass)
they have different constructors so I can’t add collisionShape to BetterCharacterControl.

You are moving the spatial after you attached the control to it. If i understood the concept correctly this will not effect the control. It remains at (0,0,0). You should be able to observe this in the debug View.

Try to move the Spatial before you add the Control:

player.setLocalTranslation(new Vector3f(60, 10, -60));
player.addControl(characterPlayer);
1 Like

Yes, that was the mistake :slight_smile: Thx a lot :slight_smile: