Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 rotate 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 facing rather than the direction the character is facing when you press the forward key. This is common in console games.

Getting ready

Out of convenience, we...