# Make AI continuously follow player (Behavior Tree)

**URL:** <https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949>\
**Category:** AI\
**Tags:** Behavior-Tree, ai-move-to, unreal-engine, question\
**Created:** [September 17, 2018, 2:53pm UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949 "2018-09-17T14:53:42Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [September 17, 2018, 2:53pm UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/1 "2018-09-17T14:53:42Z")

</div>

Hello.

I have an AI character, which should continuously follow player.

His behavior tree looks like:

1. Find player position
2. Project it on navigation
3. MoveTo that position.

The problem - when player changes his position to a new one, AI character still moves to previous player position, then stops, find and project new player position and so on. But I want this AI character to “correct” his MoveTo on execution.

I tried to move this branch into separate sequence with service, which checks previous and current player positions and aborts itself if they are not match, but result is the same - AI character still stops everytime.

So, is there any solution to make AI character follow player CONTINUOUSLY.

Thank you!

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [September 17, 2018, 10:18pm UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/2 "2018-09-17T22:18:31Z")

</div>

why not just set the move to target to be the player actor instead of their location. that way the only time they will stop is if blocked by walls, lack of nav mesh, or they accomplish in reaching the player. basically it will make them run to the player continuously.

---

<div class="post-metadata">

**Author:** ![sjcobs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sjcobs/32/918649_2.png) [@sjcobs](https://forums.unrealengine.com/u/sjcobs)\
**Post date:** [September 18, 2018, 4:38am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/3 "2018-09-18T04:38:56Z")

</div>

Use "move to’ node in the behavior tree and set the blackboard key to a ‘Target Actor’, and only allow execution if the blackboard value ‘Target Actor’ is set. You could set and clear the ‘Target Actor’ from within the AI controller if you are using AI Perception.

Also you might want to put the ‘Default Focus’ service on the ‘move to’ if you want your AI to focus on your ‘Target Actor’, this will allow you to rotate the AI to face the ‘Target Actor’, or you could simple check the ‘Observe Blackboard Value Tolerance’ within the ‘move to’ node to check every so often if the ‘Target Actor’ has changed location.

Finally you can run a check by using a built in decorated called ‘Is At Location’, so you can do something when your AI reached the ‘Target Actor’.

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [September 18, 2018, 6:55am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/4 "2018-09-18T06:55:46Z")

</div>

> Use "move to’ node in the behavior  
> tree and set the blackboard key to a  
> ‘Target Actor’, and only allow  
> execution if the blackboard value  
> ‘Target Actor’ is set.

How? MoveTo task accepts only Vector type keys.

![253966-2018-09-18-0954.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/d/a1d42cea3c702cefd8e4f5857c7e0b0f6a928f02.png)

---

<div class="post-metadata">

**Author:** ![Samuelb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Samuelb](https://forums.unrealengine.com/u/Samuelb)\
**Post date:** [September 18, 2018, 7:38am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/5 "2018-09-18T07:38:01Z")

</div>

Does this help you at all? I’m not sure I understand the problem exactly

 ![253977-settingplayerposandref.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/f/71f063b7a6905e3b858a9b824375156de9f6efee.png)

---

<div class="post-metadata">

**Author:** ![Samuelb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Samuelb](https://forums.unrealengine.com/u/Samuelb)\
**Post date:** [September 18, 2018, 7:39am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/6 "2018-09-18T07:39:29Z")

</div>

This is inside in my Bots brain BTS from the “Event receive tick” execution

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [September 18, 2018, 7:59am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/7 "2018-09-18T07:59:11Z")

</div>

I’m doing it already.

Problem is - if player moves, AI moves to last player location, stops, and moves to new location. But I want it to move without any stops, and always to current player location.

---

<div class="post-metadata">

**Author:** ![Samuelb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Samuelb](https://forums.unrealengine.com/u/Samuelb)\
**Post date:** [September 18, 2018, 8:03am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/8 "2018-09-18T08:03:49Z")

</div>

Hmm ok thats wierd i’m not having that issue. It might be the way my ai works for my specific game.  
Its been a while since I’ve done this project, i’ll try to dig more if I can figure some solution

---

<div class="post-metadata">

**Author:** ![Samuelb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Samuelb](https://forums.unrealengine.com/u/Samuelb)\
**Post date:** [September 18, 2018, 8:06am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/9 "2018-09-18T08:06:57Z")

</div>

What does your behavior tree look like?

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [September 18, 2018, 8:10am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/10 "2018-09-18T08:10:07Z")

</div>

AI checking is he can attack player by weapon range, if not - to move to player (enemy) location.

 ![253967-2018-09-18-1108.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/e/b1e6eccf035780efcae5499a3680fc7b1eac8de2.png)

---

<div class="post-metadata">

**Author:** ![Samuelb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Samuelb](https://forums.unrealengine.com/u/Samuelb)\
**Post date:** [September 18, 2018, 8:19am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/11 "2018-09-18T08:19:14Z")

</div>

Ok, I think there might be an issue with using a decorator for this functionality (I could be wrong). The way I set up my Bot is that I’m checking how far away I’m from the player → setting different bot states and based on the blackboard condition I’m activating different BTTasks. I think I had a similar issue when I tried using decorators. Here is a reference of how my Tree is set up. (Again this could be completely wrong).

 ![253978-botaitree.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/8/a285cbe4dceb8560b48f2f060c6a5cd53220baf1.png)

Hopefully this helps you narrow down the problem.

-Samuelb

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [September 18, 2018, 11:43am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/12 "2018-09-18T11:43:42Z")

</div>

Problem not in decorator, but, as I think, in MoveTo task. Once controller gets valid MoveTo location, it starts to execute until character reaches it. Only after that whole branch is restarted, controller gets new MoveTo location, and executes it again.

This works if AI character gets enemy location who stands on the same place. But if enemy location is changes continuously (so player trying to escape from this ai character), this not work. Ai character always stops in some intermediate locations while chasing his enemy.

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [September 18, 2018, 11:46am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/13 "2018-09-18T11:46:09Z")

</div>

I also tried to update location value in blackboard with Tick, but it looks like MoveTo uses only location it gets when started execution.

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [September 18, 2018, 11:59am UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/14 "2018-09-18T11:59:34Z")

</div>

I’m just stupid, sorry.

I have created my own version of MoveTo task and it works as I want.

Anyway, thank you all for you advice!

 ![253969-2018-09-18-1457.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/1/9/3198171fc74871ed52ead485bfda89caa387b468.png)

---

<div class="post-metadata">

**Author:** ![Samuelb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Samuelb](https://forums.unrealengine.com/u/Samuelb)\
**Post date:** [September 18, 2018, 8:17pm UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/15 "2018-09-18T20:17:44Z")

</div>

I’m glad to hear you found the solution redbox! =)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_ea7f2fa2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ea7f2fa2](https://forums.unrealengine.com/u/anonymous_user_ea7f2fa2)\
**Post date:** [October 10, 2019, 1:32pm UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/16 "2019-10-10T13:32:20Z")

</div>

Thx it worked, when you use the good node ! move ai and not move actor !

 ![289729-moveto.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/8/e686eb78e55b659a186b18823cbcf937675450b6.jpeg)

---

<div class="post-metadata">

**Author:** ![andrea.g137](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@andrea.g137](https://forums.unrealengine.com/u/andrea.g137)\
**Post date:** [February 13, 2022, 2:09pm UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/17 "2022-02-13T14:09:09Z")

</div>

Hello, sorry if I reactivate this post but I have the same problem and the solution is no longer visible. Would it be possible to put it back? Thank you very much

---

<div class="post-metadata">

**Author:** ![GattoDev\_0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GattoDev\_0](https://forums.unrealengine.com/u/GattoDev_0)\
**Post date:** [February 10, 2026, 8:34pm UTC](https://forums.unrealengine.com/t/make-ai-continuously-follow-player-behavior-tree/433949/18 "2026-02-10T20:34:44Z")

</div>

hello i have a q why when i press on bkacboard key it shows only the self actor
