Unity 2018 By Example(Second Edition)
上QQ阅读APP看书,第一时间看更新

Chapter 3. Creating a Space Shooter

This chapter enters new territory now as we begin development work on our second game, which is a twin-stick space shooter. The twin-stick genre simply refers to any game in which the player input for motion spans two dimensions or axes, typically one axis for movement and one for rotation. Example twin-stick games include Zombies Ate My Neighbors and Geometry Wars. Our game will rely heavily on coding in C#, as we'll see. The primary purpose of this is to demonstrate by example just how much can be achieved with Unity procedurally (that is, via script), even without using the editor and level-building tools. We'll still use these tools to some extent but not as much here, and that's a deliberate and not an accidental move. Consequently, this chapter assumes that you have not only completed the game project created in the previous two chapters, but also have a good, basic knowledge of C# scripting generally, though not necessarily in Unity. So, let's roll up our sleeves, if we have any, and get stuck in making a twin-stick shooter. This chapter covers the following important topics as well as others:

  • Spawning and prefabs
  • Twin-stick controls and axial movement
  • Player controllers and shooting mechanics
  • Basic enemy movement and AI

Note

Remember to see the game created here, and its related work, in abstract terms, that is, as general tools and concepts with multiple applications. For your own projects, you may not want to make a twin-stick shooter, and that's fine. I cannot possibly know every kind of game that you want to make. However, it's important to see the ideas and tools used here as being transferrable, as being the kind of things you can creatively use for your own games. Being able to see this is very important when working with Unity or any engine.