Make a custom NPC that follows the player

Hello, I’m trying to create a custom NPC (I want to use my own model). Basically, I just want to: spawn the NPC, and have it follow me continuously. I’ve searched on forums but couldn’t find anything usable, so I hope for some assistance.

I’m sorry for the inconvenience. I tried to learn and create according to this guide:
https://dev.epicgames.com/documentation/en-us/uefn/create-custom-npc-behavior-in-unreal-editor-for-fortnite



# Get the Leash Interface, which lets you confine a guard to a certain area.
Leashable := Character.GetFortLeashable[]


# Leash the guard to a position so they stay between 500 and 1000
# cm of the position they're leashed to
Leashable.SetLeashPosition(NPCSpawnPoint, InnerRadius := 500.0, OuterRadius := 1000.0)

# Leash the guard to an agent so they stay between 500 and 1000
# cm of the agent they're leashed to
Leashable.SetLeashAgent(AgentToFollow, InnerRadius := 500.0, OuterRadius := 1000.0)
# Clear all leashes on the guard
Leashable.ClearLeash()

but when I reached this section, it reported an error (AgentToFollow). I tried to find a solution but haven’t been successful yet. I hope to receive some help.

AgentToFollow is not in the code base I don’t think. I think that is a variable that needs to be set. Your player is the agent to follow and thus needs to be set as such. But that tutorial seems a bit excessive. Try this one: 20 Guards Following Player Using Leash

1 Like

Thank you, i will try.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.