Game Development Reference
In-Depth Information
7. The following RotationSpeed method defines how quickly the camera
moves when moving it:
chaseCam.setRotationSpeed(10);
8. Now, we have a basic setup for ChaseCamera . Let's see what we need to do to
the GameCharacterControl class to suit this kind of game.
9. We can easily apply the behavior where forward is the direction of the camera by
replacing the two lines, and setting modelForwardDir and modelLeftDir
in the update method:
Vector3f modelForwardDir =
cam.getRotation().mult(Vector3f.UNIT_Z).multLocal(1,
0, 1);
Vector3f modelLeftDir =
cam.getRotation().mult(Vector3f.UNIT_X);
10. Since we don't directly control the characters' view direction anymore, we can set
it to always be the last direction the character faced (when moving) as follows:
viewDirection.set(walkDirection);
11. At the end of the method, we mustn't forget to apply it to PhysicsCharacter
as follows:
setViewDirection(viewDirection);
Search WWH ::




Custom Search