Project Update: Enemy setup

Andrea Alicino
2 min readSep 8, 2021

--

We introduce an enemy into our 3D prototype, now it looks like just a square-based parallelepiped, but imagine it as a brain-hungry zombie.

a terrifying zombie

First I need to make the zombie chase the player. As for the player, I will use the character controller. But in this case, it will not take external input.

We know that to move an object we need a direction and a velocity.
The direction is calculated by subtracting the position of the zombie from that of the player.
The velocity is calculated by multiplying the speed by the direction.

If we leave it like that, we will notice that the zombie will immediately crash into the player. To avoid this behavior, it is enough to apply the Normalize() method to our vector3 direction. Basically, it changes its magnitude to 1 making the displacement more homogeneous.

The second thing to look at is the rotation of the zombie, at the moment it only moves in the direction of the player. To solve this problem, there is a quick solution. It is enough to modify the rotation of the enemy with the LookRotation method and pass as a parameter the direction that we calculated previously.

--

--

Andrea Alicino
Andrea Alicino

Written by Andrea Alicino

Game Developer Unreal Engine/Unity. Computer science graduate. Seeking new opportunities.

No responses yet