Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Create Enemy Movement | Enemy Blueprints
Unreal Engine FPS Game
course content

Course Content

Unreal Engine FPS Game

Unreal Engine FPS Game

1. Unreal Engine Introduction
2. The Character Blueprint
3. Enemy Blueprints
4. Level Design and Aesthetics
5. User Interface and Sound Effects
6. Gameplay Logic
7. Packaging for Windows

bookCreate Enemy Movement

In this chapter, we are going to create some functionality so that the enemy moves towards us. To make it a bit more varied, we will also set up a system where we can choose which enemies will move towards us and make those that are stationary constantly look at our player character!

For this purpose we will use our Event Tick. Now this is not something that a professional game programmer would do as we usually try to limit the use of Event Tick since it can demand a lot of resources once the code gets too complicated, but for this simple purpose, it should be fine.

The function that we want to connect to our Event Tick is called Simple Move To Actor which requires a Controller and a Goal. For the controller, we search for Get Controller and choose the respective node and plug it in. Then, since our target is the player pawn, we search for Player Pawn and plug that into Goal as shown below.

Next, we move to our FIrstPersonMap and add a NavMeshBoundsVolume to the scene.

Make the NavMeshBoundsVolume large enough to cover all of your level. Then go to build and press build all levels. If you see a pop up asking you what to do with HLODs, just press Delete HLODS and let Unreal Engine build. Once the build is done, click on Show and check the box Navigation. This should highlight all the areas that your NavMesh is affecting by making them green.

Next, make a Boolean variable, and name it IsAMovingEnemy and make sure to make it visible by clicking on the eye icon (OR check the box Instance Editable), and then also check the box Expose on Spawn.

Make a branch and connect it to the event tick, and connect its True pin to Simple Move To Actor. Drag the variable IsAMovingEnemy into the graph and connect it to the branch.

Drag out from the False pin and type in Set Actor Rotation. Now right click somewhere else and search for Find Look at Rotation. Then search for Get Actor Location and plug that into the Start pin of Find Look At Rotation. For the target, we want to get our Player Pawn first, and drag out of the blue pin and search for Get Actor Location. Connect that to the Target of the rotation finder and then plug in the output (the purple pin) into Set Actor Rotation.

Now if you place some of the enemy blueprints into your scene you can choose some of them and make them chase the player by selecting them, looking into their details panel, and under Defaults, check the box for Is A Moving Enemy.

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 2
We're sorry to hear that something went wrong. What happened?
some-alt