RAMMING SPEED! Creating An Aggressive Enemy Ship
For the creation of an “aggressive” enemy, let’s add a kamikaze ship that rams the player if you get too close! Watch out, they’re dangerous!

Today’s Objective: Create an aggressive enemy type that attempts to turn and ram the player if they get too close.
In the Enemy Movement script, I add these variables to control the ram:

In the Update method, after the normal movement code, if the enemy can ram and it is not destroyed yet, check for the chance to ram the player:

Then create the function for checking for a valid ram chance — “CheckForRamChance()”:

Finally, create the function that will actually do the ramming — “RamInPlayersDirection()”:

The result:
