The most basic AI-controlled follow behavior is available as a simple function node. All you have to do is perform the steps that follow to get one AI-controlled unit to follow a unit or object.
Have a UE4 project ready with a simple landscape or set of geometry on the ground— ideally, with a cul-de-sac somewhere in the geometry for testing out AI movement functions. Create a Nav Mesh over this geometry so that the AIMoveTo
function will work as described in the previous recipe.
Create a Nav Mesh for your level's geometry as described in the preceding recipe, Laying down a Navigation Mesh.
Create a Blueprint class deriving from
Character
by finding theCharacter
class in the Class Viewer, right-clicking on it, and selecting Create Blueprint Class…Name your Blueprint class
BP_Follower
.Double-click on the
BP_Follower
class to edit its Blueprint.In the
Tick
event, add anAIMoveTo
node, which moves towards the player pawn (or any other unit) as follows...