New Enemy: Mine Layer Pt 1

Another Enemy type we will be adding is a Mine Layer. There goal is to deploy Mines where the Player with trip them and explode. But before we can make a MineLayer, We need Mines.

Our mine is made of two key components, A main body and a detection area. Both parts an collider that will trigger the explosion and Damage the player. Let’s start with the main body.

The Mine has several methods that are the same as the basic Enemy Class (dimmed out above) But also some key differences.

Event Declaration so that the Player and UIManager can do the things they need to with the information of the Mine’s destruction.

The Slowdown Coroutine is called by the Mine Layer when it instantiates the Mine and is used to create the slow spread out effect. It is a basic countdown timer that reduces the _speed to zero to stop the mine from moving.

We also have a public Explosion() that allows the Detection portion to set off the explosion effect and send the whole mine back to the Pool.

And reduced OnTriggerEnter() to account for the Mine only caring about whether it is hit by the Player or their Laser.

As for the Detection part of the mine, We have a simple class that holds a reference to the main Mine Game Object and a OnTriggerEnter().

Since the Collider for this part is extended out away from the Mine, When the Mine spins in place, it produces something like a radar effect. So as the the Player passes into the area, or the area passes the player, It causes the Mine to explode and cause Damage.

Next time, We will talk about how to the Mine Layer can know when to deploy the mines.

A Unity Developer with a fondness for Fantasy games and the challenge of pushing boundaries.