# Make a custom NPC that follows the player

**URL:** <https://forums.unrealengine.com/t/make-a-custom-npc-that-follows-the-player/1772683>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [March 26, 2024, 8:19am UTC](https://forums.unrealengine.com/t/make-a-custom-npc-that-follows-the-player/1772683 "2024-03-26T08:19:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hotuan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hotuan](https://forums.unrealengine.com/u/hotuan)\
**Post date:** [March 26, 2024, 8:19am UTC](https://forums.unrealengine.com/t/make-a-custom-npc-that-follows-the-player/1772683/1 "2024-03-26T08:19:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hotuan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hotuan](https://forums.unrealengine.com/u/hotuan)\
**Post date:** [March 26, 2024, 9:06am UTC](https://forums.unrealengine.com/t/make-a-custom-npc-that-follows-the-player/1772683/2 "2024-03-26T09:06:22Z")

</div>

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](https://dev.epicgames.com/documentation/en-us/uefn/create-custom-npc-behavior-in-unreal-editor-for-fortnite)

```auto

# 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.

---

<div class="post-metadata">

**Author:** ![mikezteh69](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mikezteh69/32/915063_2.png) [@mikezteh69](https://forums.unrealengine.com/u/mikezteh69)\
**Post date:** [March 26, 2024, 7:56pm UTC](https://forums.unrealengine.com/t/make-a-custom-npc-that-follows-the-player/1772683/3 "2024-03-26T19:56:29Z")

</div>

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](https://dev.epicgames.com/community/snippets/M1JE/fortnite-20-guards-following-player-using-leash)

---

<div class="post-metadata">

**Author:** ![hotuan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hotuan](https://forums.unrealengine.com/u/hotuan)\
**Post date:** [March 27, 2024, 12:55am UTC](https://forums.unrealengine.com/t/make-a-custom-npc-that-follows-the-player/1772683/4 "2024-03-27T00:55:53Z")

</div>

Thank you, i will try.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [April 26, 2024, 12:56am UTC](https://forums.unrealengine.com/t/make-a-custom-npc-that-follows-the-player/1772683/5 "2024-04-26T00:56:20Z")

</div>

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