Choose your operating system:
Windows
macOS
Linux
Overview
This document will guide you through the preliminary steps of creating a Level and AI Agent to learn about the Custom Areas and Query Filters in the Navigation System.
You can also download the full sample project, which includes all the material covered in this guide.
Objectives
Create a new Level and set up navigation by placing a Navigation Mesh Actor in the Level.
Modify the ThirdPersonCharacter Blueprint to navigate toward its target by using specific Query Filters.
1 - Required Setup
In the New Project Categories section of the Unreal Project Browser, select Games and click Next.
Select the Third Person template and click Next.
Select the Blueprint and No Starter Content options and click Create Project.
Section Results
You have created a new Third Person project and are now ready to learn about creating Area Classes and Navigation Query Filters.
2 - Creating Your Test Level
Click File > New Level on the Menu Bar.
Select the Default Level.
Select the Floor Static Mesh Actor in the World Outliner and on the Details panel, set the Scale to X = 10, Y = 10, Z = 1.
Go to the Place Actors panel and search for Nav Mesh Bounds Volume. Drag it into the Level and place it on the floor mesh.
With the Nav Mesh Bounds Volume selected, go to the Details panel and set the Scale to X = 5, Y = 10, Z = 1.
Go to the Place Actors panel and go to the Basic category. Drag a Sphere Actor into the Level.
Section Results
In this section you created a new Level and added a Navigation Mesh and a Sphere Actor. You are now ready to create an Agent that will walk toward the sphere goal.
3 - Creating Your Agent
In this section you will create an Agent that navigates to its target Actor.
In the Content Browser, right-click and select New Folder to create a new folder. Name the folder NavigationSystem.
In the Content Browser, go to ThirdPersonBP > Blueprints and select the ThirdPersonCharacter Blueprint. Drag it to the NavigationSystem folder and select the option Copy Here.
Navigate to the NavigationSystem folder and rename the Blueprint to BP_NPC_CustomZone. Double-click the Blueprint to open it and go to the Event Graph. Select all input nodes and delete them.
Right-click the Event Graph, then search for and select Add Custom Event. Name the event MoveNPC.
Go to the My Blueprint panel and click the Add (+) button next to Variables to create a new variable. Name the variable Target.
Go to the Details panel and click the Variable Type dropdown. Search for Actor and select the Object Reference. Enable the Instance Editable checkbox.
Drag the Target variable to the Event Graph and select the option Get Target. Drag from the Target node, then search for and select the Is Valid macro, as shown below.
Right-click the Event Graph, then search for and select Get reference to self.
Drag from the Self node, then search for and select Get AIController.
Drag from the AI Controller node, then search for and select Move to Actor.
Connect the Is Valid pin of the Is Valid node to the Move to Actor node. Set the Acceptance Radius of the Move to Actor node to 50. Drag the Target variable and connect it to the Goal pin of the Move to Actor node.
Right-click the Filter Class pin of the Move to Actor node and select Promote to Variable. Go to the Details panel and enable the Instance Editable checkbox.
Right-click the Event Graph, then search for and select Event Begin Play. Drag from the Event Begin Play node and search for and select MoveNPC.
Compile and save the Blueprint. The final Blueprint should look like the image below.
Drag the BP_NPC_CustomZone Blueprint into your Level. Navigate to the Details panel and click the dropdown next to Target. Search for and select Sphere, as seen below.
Press Simulate and watch as your Agent moves toward the Sphere.
Section Results
In this section you created an Agent that navigates toward its goal and can use a Navigation Query Filter. You are now ready to learn about adding Custom Navigation Areas and Query Filters.