private void initPlayer() { playerControl = new CharacterControl( new CapsuleCollisionShape( (cubesSettings.getBlockSize() / 2), cubesSettings.getBlockSize() * 2), 0.05f); playerControl.setJumpSpeed(25); playerControl.setFallSpeed(20); playerControl.setGravity(70); playerControl.setPhysicsLocation( new Vector3f(5, terrainSize.getY() + 5, 5).mult(cubesSettings.getBlockSize())); bulletAppState.getPhysicsSpace().add(playerControl); }
@Override public void simpleUpdate(float lastTimePerFrame) { float playerMoveSpeed = ((cubesSettings.getBlockSize() * 6.5f) * lastTimePerFrame); Vector3f camDir = cam.getDirection().mult(playerMoveSpeed); Vector3f camLeft = cam.getLeft().mult(playerMoveSpeed); walkDirection.set(0, 0, 0); if (arrowKeys[0]) { walkDirection.addLocal(camDir); } if (arrowKeys[1]) { walkDirection.addLocal(camLeft.negate()); } if (arrowKeys[2]) { walkDirection.addLocal(camDir.negate()); } if (arrowKeys[3]) { walkDirection.addLocal(camLeft); } walkDirection.setY(0); walkDirection.normalize(); walkDirection.multLocal(lastTimePerFrame * 10); playerControl.setWalkDirection(walkDirection); cam.setLocation(playerControl.getPhysicsLocation()); }