Chapter 12. 3D Collision Detection and Shooting

OK...here we go. Fasten your seatbelts; we're coming to the final stretch. In the last chapter, you built a flying camera and discussed differences between that and a land-based camera. Then, you took the code you've been building in this 3D section of the book and created a customized camera for your game. In this chapter, you'll add some game logic and support for shooting and collision detection. We've got a lot to do, so let's get to it.

This chapter picks up with the code that you finished with in Chapter 11. Open the 3D Game project and use it for the examples and walkthroughs in this chapter.

Tip

In the source code you've download for the book, you'll find that Chapter 11 has two projects: Flying Camera, which holds the code for the 3D flying camera you created in the first portion of that chapter, and 3D Game, which holds the code for the stationary, customized camera you created in the second part of that chapter. Make sure you use the project called 3D Game for this chapter.

Creating a Moving Enemy

Right now, you have a customized camera that rotates in yaw and pitch directions while looking at a spinning spaceship. That's pretty sweet, and you may be tempted to release your game now and see if you can pull some users away from World of Warcraft, making millions on monthly subscriptions. I'd caution you to take a step back for a minute, though, and realize that you've still got some work to do before you get to that point.

In the ...

Get Learning XNA 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.