8 Creating a third-person 3D game: player movement and animation

 

This chapter covers

  • Adding real-time shadows to the scene
  • Making the camera orbit around its target
  • Changing rotation smoothly using the Lerp algorithm
  • Handling ground detection for jumping, ledges, and slopes
  • Applying and controlling animation for a lifelike character

In this chapter, you’ll create another 3D game, but this time you’ll be working in a new game genre. In chapter 2, you built a movement demo for a first-person game. Now you’re going to write another movement demo, but this time it’ll involve third-person movement. The most important difference is the placement of the camera relative to the player: A player sees through their character’s eyes in first-person view, and the camera is placed outside the character in third-person view. This view is probably familiar to you from adventure games, like the long-lived Legend of Zelda series, or the more recent Uncharted series of games. (Skip ahead to figure 8.3 if you want to see a comparison of first-person and third-person views.)

The project in this chapter is one of the more visually exciting prototypes we’ll build in this book. Figure 8.1 shows how the scene will be constructed. Compare this with the diagram (figure 2.2) of the first-person scene we created in chapter 2.

Figure 8.1 Roadmap for the third-person movement demo
Macintosh HD:Users:jhocking:Documents:writing:manning:uia 3e:updated graphics:ch08:CH08_F01_Hocking.png

8.1 Adjusting the camera view for third-person

8.1.1 Importing a character to look at

8.1.2 Adding shadows to the scene

8.1.3 Orbiting the camera around the player character

8.2 Programming camera-relative movement controls

8.2.1 Rotating the character to face movement direction

8.2.2 Moving forward in that direction

8.3 Implementing the jump action

8.3.1 Applying vertical speed and acceleration

8.3.2 Modifying the ground detection to handle edges and slopes

8.4 Setting up animations on the player character

8.4.1 Defining animation clips in the imported model

8.4.2 Creating the animator controller for these animations

8.4.3 Writing code that operates the animator

8.5 Summary

sitemap