NPC Patrol System for Unreal Engine will allow you to create patrolling paths on a level and make your NPCs execute actions easily.
Hey Indiewatchers! I'm Víctor Hernández Molpeceres, co-founder and programmer at Tessera Studios, and I would like to show you how to use the patrol system that we implemented on our first game, Intruders: Hide and Seek.
Once we finished the game, we thought it would be interesting to "break" the game into small encapsulated pieces and upload them to the UE4 Marketplace for sale. With that in mind, we created the Waypoint Patrol System, our first plugin for the engine.
Intention of the plugin
This plugin aims to help the developer to create patrolling paths on a level and make your NPCs execute actions easily. It offers 6 pre-configured actions and the possibility to easily create custom ones that match your needs, using blueprints or code.
To get started with a simple test, you will need to create 5 simple things:
- A blackboard with a key of type Object and Base Class Waypoint named CurrentWaypoint.
- A behavior tree using that blackboard with the included Patrol task hanging from a Selector which hangs from the Root behavior tree node.
- An AI Controller with a Run Behavior Tree node called from Begin Play event and with the behavior tree selected on the BTAsset parameter.
- A character inherited actor with Character Movement Component, Audio Component and the included Waypoint Patrol Component. Set a mesh to the skeletal mesh component, uncheck Use Controller Rotation Yaw (Pawn category), set the previously created AI Controller on AI Controller Class (Pawn category) and check Orient Rotation to Movement on the Character Movement Component. You can also use a pawn inherited actor instead of a character, but obviously you won’t be able to use the Play animations action.
- A level to place all the stuff with a Nav Mesh Bounds instantiated on the floor. Also, on the Begin Play of the level blueprint, set the first patrol waypoint using the function Set Current Waypoint of the Waypoint Patrol Component of the pawn.
Once you have all of this created, drop some BP_Waypoint on the level, drop the previously created character and set a patrol adding Possible Next Waypoints on each waypoint. Hit Play and you should see the pawn patrolling through every waypoint.
And that's it! I hope you find this plugin useful for your AI needs. If you have more questions about it you can write to us on the Unreal Engine marketplace or directly to firstname.lastname@example.org
If you prefer, you can watch a little preview of this tutorial on the video below and better learn how to control your NPCs actions on Unreal Engine: