Chapter 2. Cameras and Game Controls

This chapter contains the following recipes:

  • Creating a reusable character control
  • Attaching an input AppState object
  • Firing in FPS
  • Firing non-instant bullets
  • Creating an RTS camera AppState object
  • Selecting units in RTS
  • Making the camera follow units
  • Following a character with ChaseCamera
  • Adding a game controller and joystick input
  • Leaning around corners
  • Detecting cover automatically in a third-person game

Introduction

This chapter is about controlling avatars and cameras for various game types. Whether your game is a first person shooter (FPS), role playing game (RPG), or real-time strategy (RTS) game, you'll learn some tricks that will help you get past tricky obstacles.

The chapter will rely heavily on the ActionListener and AnalogListener interfaces. These are essential when listening for the player input in jMonkeyEngine. The ActionListener interface will pick up any binary input such as keyboard keys or mouse buttons. The AnalogListener interface listens for mouse and joystick movements and other input that is either on or off.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.130.199