Game Development Reference
In-Depth Information
Following a character with ChaseCamera
In this recipe, we'll explore jMonkeyEngine's
ChaseCamera
class. This camera is a bit
different from the previous cameras we've explored since we don't have direct control over
its position. It is not like the camera-on-a-stick method we tried in the
Creating a reusable
character control
recipe. While it still follows and looks at the character, it can float around
the character more freely and also be controlled by the player.
The default control for the camera is to hold down the left mouse button and drag it to ro-
tate the camera around the character. This is a very common control pattern in third-person
games on consoles, where you rotate the camera with the left stick and control the character
with the right.
We will implement a behavior where the character moves in the direction the camera is fa-
cing rather than the direction the character is facing when you press the forward key. This
is common in console games.