Creating an Enemy that Follows the Player in Unity.

Enemy with new movement type.

Rusben Guzman
Aug 19, 2021

Objective: Create a new movement type to make the enemy move towards the player.

In this case I create a new movement type. When the _movementType variable is equal to 3 I use the Vector3.MoveTowards() function. This function translates the gameObject passing as parameters the origin, the target and the distance. In this case I passed the enemy as an origin, the player as a target and the speed as the distance.

That’s all!!! We have an enemy that can move towards the player.

--

--

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