61-Aggressive Enemy

In this post, a new type of enemy will be created. It will move along the same path as the normal enemy. However, when it is close to the player, it will ram into the player instead.

This enemy will inherit most of the behavior of the parent Enemy class, except that in its movement, it will switch to an aggressive mode depending on its distance from the player.

A method of switching aggressive mode (a bool flag) is created, which mainly detects the distance between two transform positions. The position of the player is passed in as a parameter in this method.

A detection range of 5.0f is given here.

With this method, the movement mode of the aggressive enemy can be adjusted.

--

--