Hi,
I’m fairly new to jme3, and try to implement a dynamic labyrinth the user navigates through. It worked quite well with the CharacterControl
according to the tutorials from the documentation. But for some functionality I switched to the BetterCharacterControl
. Since then, the performance dropped dramatically (before: 100s of frames per second, now 3-4 frames per second).
What could be the reason for this issue?
I already tried to optimise according to what I found, i.e. ensured that the labyrinth itself is static, using GeometryBatchFactory.optimize()
on it, using a CompoundCollisionShape
via CollisionShapeFactory.createMeshShape()
, but nothing really helped.
The labyrinth itself is automatically generated and built by using Box
geometries, each box representing one wall (it’s really just a first experiment with jme).
Here’s the code by which I add the labyrinth to the physics space (assuming collision control is the issue):
CollisionShape mazeShape = CollisionShapeFactory.createMeshShape(this.maze.getRootNode());
this.landscape = new RigidBodyControl(mazeShape, 0.0f);
this.maze.addControl(this.landscape);
This is the character control setup:
this.playerNode = new Node(PLAYER_NAME);
this.playerNode.setLocalTranslation(cam.getLocation());
this.app.getRootNode().attachChild(this.playerNode);
this.playerControl = new BetterCharacterControl(1f, 4f, 10f);
this.playerControl.setJumpForce(new Vector3f(0, 10, 0));
this.playerControl.setGravity(new Vector3f(0, -20, 0));
this.playerNode.addControl(this.playerControl);
And finally it gets added to an bullet app state:
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().add(this.landscape);
bulletAppState.getPhysicsSpace().add(this.playerControl);
Anything obvious I did wrong?