# What is the proper way to access player location from BTTask

**URL:** <https://forums.unrealengine.com/t/what-is-the-proper-way-to-access-player-location-from-bttask/319717>\
**Category:** Editor Scripting\
**Tags:** Behavior-Tree, reference, bttask, unreal-engine, question\
**Created:** [May 25, 2015, 3:38pm UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-access-player-location-from-bttask/319717 "2015-05-25T15:38:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_42126980](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_42126980](https://forums.unrealengine.com/u/anonymous_user_42126980)\
**Post date:** [May 25, 2015, 3:38pm UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-access-player-location-from-bttask/319717/1 "2015-05-25T15:38:31Z")

</div>

Hi, I need to get actor location from BTTask to calculate distance between enemy AI and player, then do something after. I’ve tried use get player controller and cast to my characterBP to access the actor location, however the behavior tree seems like only execute the “Search” BTTask but not running the sequence node. Below is my setup of the behavior tree for the enemyAI.

BehaviorTree:

 ![44080-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/e/2/4e213fd1a003b5f9097ca63c6d72efe9b4634d50.png)

Search BTTask:

 ![44091-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/c/4/7c45c4e6b43483f5ec6b9a18c5dc0987ad19a027.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_42126980](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_42126980](https://forums.unrealengine.com/u/anonymous_user_42126980)\
**Post date:** [May 26, 2015, 10:25am UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-access-player-location-from-bttask/319717/2 "2015-05-26T10:25:07Z")

</div>

Ok i solved it by adding branch before finish execute is being called with condition of “Player is within search radius” instead of keep on success finish execute at every tick.
