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.
This recipe will expand on the
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 ...