Creating an Enemy that Follows the Player in Unity.
Enemy with new movement type.
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.