Enemies

The next step is to create something for the player to shoot and destroy, which can also destroy us, namely, enemy characters. These take the form of roaming spaceships that will be spawned into the scene at regular intervals and will follow the player, drawing nearer and nearer. Essentially, each enemy represents a complex of multiple behaviors working together and these should be implemented as separate scripts. Let's consider them in turn:

  • Health: Each enemy supports health functionality. They begin the scene with a specified amount of health and will be destroyed when that health falls below 0. We already have a Health script created to handle this behavior.
  • Movement: Each enemy will constantly be in motion, traveling in a straight line ...

Get Unity 5.x By Example 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.