O'Reilly logo

jMonkeyEngine 3.0 Cookbook by Rickard Edén

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required