Galaxy Shooter 2D — Avoider, Reckless, and Watcher

More enemies join the fight! Good luck, player!

Pablo Gómez Platón
4 min readJun 6, 2021

The game has now a real sense of challenge with the Bomber and Toxic enemies added in, but what if I add even more? It’s time to complete the enemy rooster with these three new enemies: Avoider, Reckless, and Watcher!

Avoider

This agile enemy will react to the player lasers and move out of the way to avoid getting hit. It will require the player to shoot it at a close range, or using a special weapon to get rid of them easily.

Characteristics:

Laser and Laser Beam avoidance. Like the Heat Seeking Lasers, I’ve also used OverlapCircle to get the lasers and the beam colliders. However, the laser detection is used to get an horizontal direction where the Avoider should move by getting the X sign value difference from the Avoider’s position and the Laser’s position.

In addition to that, there are two thresholds in this OverlapCircle:

  • One is the whole radius of the Circle which detects every laser and the Laser Beam. If the player Laser Beam is active, it will ignore all lasers and focus on avoiding it.
  • The other one is a smaller radius within the circle which is used to actually move away from the lasers. This smaller circle exists to make the avoider react at close calls, giving the player a chance to outsmart it or to make possible to shoot it at a close range and still manage to hit it.

(Also, if you’ve read the Laser Beam article, the reason it has a Pseudo-Collider is to make Avoider run away from the Laser Beam!)

Reckless

A merciless enemy that will chase you if you are near it, and it will ram you, even if that means self-destruction. This enemy will make players hope that the ship still has enough fuel to escape Reckless enemies (while avoiding the other enemy lasers!).

Characteristics:

Aggresive behaviour. If the player is on the Reckless enemy sight, the enemy will move faster towards the player and purposefully crash.

Again, to detect the player, I make use of OverlapCircle, but this time, it only accepts one result (as there is only one player ship).

Watcher

This enemy tracks your position and shoots the cannon that will likely hit you the most. Combine that with its high firerate, and you have one of the most deadly enemies out there.

Characteristics:

Position Tracking using SignedAngle. Using the same Reckless detection code to get a reference to the Player Ship, the Watcher will calculate a degree using SignedAngle (changes from a range 0…360 to -180…180 degrees with a given axis).

Then, I have to specify which cannons should the Watcher fire depending on the angle between the Watcher’s transform forward, and the Player’s position.

Avoider, Reckless and Watcher in Action

Now, with better spawn settings, this project will feel like a game that can offer a real and fun challenge!

--

--