Creating a enemy that shoot backward when the player is behind in Unity
Smarter enemies also shoot in another direction
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.