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.

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

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store