Creating Enemy with Unique Movement
Day 43- Making 2D Space Shooter Game
Objective: Moving enemy in a zig-zag pattern as if bouncing on the side wall
First we need to spawn the new type of enemy that moves in zig-zag pattern in the game.
We also need to tell the enemy Script that this is a new kind of enemy and it won’t move straight down.
This is going to set the bool for new enemy type to true which can now be used to determine what type of movement to do.
Here we determine whether to move down as a default enemy type or move in zig-zag pattern as a new enemy in Update method.
We then create a movement for the enemy to change direction when reached certain position and move in diagonal direction until it reaches a point where it changes direction.