# Best Practices and Help Regarding Behavior Tree Chase/RotateToPlayer Task and Walk Speed Adjustments Based on Player Proximity

**URL:** <https://forums.unrealengine.com/t/best-practices-and-help-regarding-behavior-tree-chase-rotatetoplayer-task-and-walk-speed-adjustments-based-on-player-proximity/1477790>\
**Category:** Programming & Scripting\
**Tags:** Behavior-Tree, service, decorator, unreal-engine, Blueprint\
**Created:** [December 5, 2023, 3:24am UTC](https://forums.unrealengine.com/t/best-practices-and-help-regarding-behavior-tree-chase-rotatetoplayer-task-and-walk-speed-adjustments-based-on-player-proximity/1477790 "2023-12-05T03:24:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![N0dnarb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@N0dnarb](https://forums.unrealengine.com/u/N0dnarb)\
**Post date:** [December 5, 2023, 3:24am UTC](https://forums.unrealengine.com/t/best-practices-and-help-regarding-behavior-tree-chase-rotatetoplayer-task-and-walk-speed-adjustments-based-on-player-proximity/1477790/1 "2023-12-05T03:24:19Z")

</div>

Hello anyone, I have a few issues I’d like clarity on, all involve each other.  
Issue 1:  
I think I’ve scripted an interesting way of combining the functionality of an NPC chasing and rotating to face a player in one task (Below Pic Related). I have a couple Questions regarding this setup:

 ![ChaseAndRotateToFacePlayer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/7/2/472de84c4e9be8d0b942e0d6e66c060154855c79.png)  
Issue 1 Question A - Does this setup ring any alarm bells or violate any best practices?  
Issue 1 Question B - This setup seems to remove my existing functionality of the NPC losing track of me using a simple MoveTo Task, the NPC will follow me forever as opposed to losing track of me when I move out of sight. Is there a way I can fix this so it works bore like the base MoveTo Task?  
 ![BehaviorTreeV2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/9/1b98cd709f19851f82f54340fbbdf289eacb9fe6.jpeg)  
Issue 2:  
I want to set up a service that checks the NPCs distance to the playerTarget and will allow me to adjust the walk speed based on that distance. I want the NPC to approach the player slowly after running to reach them initially. I’ve started a service to do this but I didn’t get far as you can see from the image below. Any specific instruciton on how to do this would be pretty rad.  
 ![SpeedService](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/f/3bf681be090b76e26c74dcbd4be9e14cca995ff5.png)  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![N0dnarb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@N0dnarb](https://forums.unrealengine.com/u/N0dnarb)\
**Post date:** [December 5, 2023, 3:36am UTC](https://forums.unrealengine.com/t/best-practices-and-help-regarding-behavior-tree-chase-rotatetoplayer-task-and-walk-speed-adjustments-based-on-player-proximity/1477790/2 "2023-12-05T03:36:31Z")

</div>

I’ve found that if I unhook the Get Player Controller from the Move To Location or Actor I can once again make the NPC lose track of me as the player although the NPC moves a bit less fluidly. Might try all this off an Event Receive Tick AI unless that would impact performance in a major way.

---

<div class="post-metadata">

**Author:** ![N0dnarb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@N0dnarb](https://forums.unrealengine.com/u/N0dnarb)\
**Post date:** [December 5, 2023, 4:18am UTC](https://forums.unrealengine.com/t/best-practices-and-help-regarding-behavior-tree-chase-rotatetoplayer-task-and-walk-speed-adjustments-based-on-player-proximity/1477790/3 "2023-12-05T04:18:44Z")

</div>

Event Receive Tick AI made no noticeable change although I did modify the Chase/Rotate Task as seen below to be cleaner and track the Blackboard Key of TargetActor rather than the generic player index.

 ![ChaseAndRotateToFacePlayer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/7/f/57f7086443e8307073c84931e61654788d19eb50.png)
