Creating an aggressive enemy that ram to the player in Unity.

Enemy will crash the player when he is close.

Rusben Guzman
2 min readAug 21, 2021

Objective: Create a new enemy type that ram the player when it is close.

First thing was to duplicate the enemy prefab and assign a new enemy ID.

Then I created a new game object as a child of the enemy, this is the area to detect when the player is close. This object have a collider and rigidbody.

In the enemy script I created a function called ram, this function changes the movement type of the player to follow the player (if you want to see how to implement this movement type read this article) and also changes the speed of the player.

I created a new script for the detection area, in this script in the start function I get the reference to the parent (in this case is the enemy) and I use the on collision enter function to check the collision with the player and call the ram function.

And good to go!!! We have an aggressive one. Be careful.

--

--

Rusben Guzman
Rusben Guzman

Written by Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

No responses yet