Beispiel #1
0
 @Override
 public void onAnimCycleDone(AnimControl ac, AnimChannel ac1, String string) {
   if (string.equals("StandUpGround")) {
     characterControl.setWalkDirection(Vector3f.ZERO);
     characterControl.setEnabled(true);
     headChannel.setAnim("IdleStanding", 0.5f);
     // Vector3f center = animControl.getSpatial().getWorldBound().getCenter();
     animControl.getSpatial().setLocalTranslation(new Vector3f(0f, -1f, 0f));
     // animControl.getSpatial().getParent().setLocalTranslation(animControl.getSpatial().getParent().getLocalTranslation().add(0f,0.1f,0f));
   }
 }
 /**
  * This is the main event loop--walking happens here. We check in which direction the player is
  * walking by interpreting the camera direction forward (camDir) and to the side (camLeft). The
  * setWalkDirection() command is what lets a physics-controlled player walk. We also make sure
  * here that the camera moves with player.
  */
 @Override
 public void simpleUpdate(float tpf) {
   camDir.set(cam.getDirection()).multLocal(0.6f);
   camLeft.set(cam.getLeft()).multLocal(0.4f);
   walkDirection.set(0, 0, 0);
   if (left) {
     walkDirection.addLocal(camLeft);
   }
   if (right) {
     walkDirection.addLocal(camLeft.negate());
   }
   if (up) {
     walkDirection.addLocal(camDir);
   }
   if (down) {
     walkDirection.addLocal(camDir.negate());
   }
   player.setWalkDirection(walkDirection);
   cam.setLocation(player.getPhysicsLocation());
 }
Beispiel #3
0
 @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());
 }