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!

Ramming Speed: The rate of motion at which a Ram rams

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:

Ram variables in the Enemy Movement script

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:

An aggressive enemy that rams the player!

--

--

--

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Spring Boot User Registration and Login

CS371G Blog: Week of 7 June — 13 June

SoccerHub x BH Network: Extending our service reach around the globe

Keep it simple!

How to Get Scopes Related with an Application Based on Subscribed APIs in WSO2 API Manager 2.1.0?

The lack of full-stack

Hack the Box: How to get the Invite Code

Kinesis vs. Kafka

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
Vincent Taylor

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

More from Medium

Making Elevators In A Unity Platformer

Jumping in between two walls in Unity

How to Add Custom Post Processing Files to Individual Cameras in Cinemachine

Quick tip — Upgrading your Unity project to High Definition Render Pipeline (HDRP)