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

Leaning around corners


If you're making a sneaker or tactical shooter game, a common feature is to be able to lean around corners. This is used to scout without being seen or shooting without exposing yourself too much. In this recipe, we'll develop a way to do this with our GameCharacterControl class. We will implement functionalities to both handle leaning with keys (such as the shoulder buttons on a gamepad) and freeform leaning with the mouse.

Getting ready

This recipe will expand on the GameCharacterControl and InputAppState classes from the beginning of the chapter, but it should be easy to adapt to your own project. It is mostly used in FPS games, and this is what we will build it for.

Leaning in this example will emulate the player character moving the upper body. To achieve this and to save us some calculations on how much the camera should be offset when leaning, we will use the built-in behavior of spatials and how translation and rotation is propagated through in a node.

How to do...