Creating a enemy that shoot backward when the player is behind in Unity

Smarter enemies also shoot in another direction

Rusben Guzman
Aug 24, 2021

Objective: Create a new enemy type that starts shooting backward when the player is behind.

First I just duplicated the enemy prefab and assigned a new enemy ID.

Then in the enemy script in the shoot laser routine I added a condition to check if the enemy ID is equals to 3 and the “y” position of the enemy is lower than the player. Then I just rotate the instantiated enemy laser by 180 degrees and with that change the enemy laser is gonna move backward.

As simple as that you have an enemy that shoots backward when the player is behind.

--

--

Rusben Guzman
Rusben Guzman

Written by Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

No responses yet