Unity2D DevLog 16 — Ramming Speed

Claudio Grassi
2 min readJun 8, 2021

As the player, you spend a lot of time avoiding collisions with your enemies. Dodging is made easy by the fact that enemies move predictably. But I want to throw a wrench into that scheme. Sometimes, trouble comes looking for you, and all you can do is face it head-on.

Objective:

Create an enemy that will attempt to ram the player.

How I went about it:

Fundamentally, this is a question of movement. I had to decide how to move an enemy normally and switch its behavior based on the player’s proximity. But before any of that, I drew some new sprites.

Fly, you fool!

With the artwork completed, I was ready to implement my Ramming Script.

I start by defining the speed and range at which the alien will attempt to ram the player. Next, I create a reference to the Player’s Transform Component. Finally, I use the Player’s Transform Component to check for distance compared to the value of Range.

--

--

Claudio Grassi
Claudio Grassi

Written by Claudio Grassi

Experienced digital artist, Unity game developer & coder with a knack for problem solving and a passion for video games.

No responses yet