To start off the chapter, we will create a class that we can use for various character-controlled purposes. The example describes an FPS character, but the method is the same for any player-controlled character.
The Control
class we'll build will be based on BetterCharacterControl
. It might be a good idea to have a look at the class or the TestBetterCharacter
example from the jMonkeyEngine test package if you want to find out how this works. Another good starting point would be the input examples from the same package.
The BetterCharacterControl
class is based on physics and requires a BulletAppState
class to be set up in the application. The steps required to do this are described in the The ImageGenerator class section in Appendix, Information Fragments. To find out more about bullet and physics, refer to Chapter 8, Physics with Bullet.