# GetWorld()GetFirstPlayerController returns NULL?

**URL:** <https://forums.unrealengine.com/t/getworld-getfirstplayercontroller-returns-null/443662>\
**Category:** AI\
**Tags:** Behavior-Tree, service, unreal-engine, question, CPP\
**Created:** [February 19, 2019, 4:48am UTC](https://forums.unrealengine.com/t/getworld-getfirstplayercontroller-returns-null/443662 "2019-02-19T04:48:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atijaf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Atijaf](https://forums.unrealengine.com/u/Atijaf)\
**Post date:** [February 19, 2019, 4:48am UTC](https://forums.unrealengine.com/t/getworld-getfirstplayercontroller-returns-null/443662/1 "2019-02-19T04:48:39Z")

</div>

Hello. I’m working with AI and am using a Blackboard/Behavior Tree in UE4 to organize data, while my Services and Tasks are made in c++. I have that set up appropriately and is working the way I expect it too, but am running into one issue.

Currently, I am attempting to retrieve a list of all connected players in the “OnBecomeRelevant” function.  
When running this bit of code, “GetFirstPlayerController()” returns NULL.

```
    OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
    {
      GetWorld()->GetFirstPlayerController(); // Returns NULL
    }

```

However GetWorld() is not null.

I can run this same code in my TickNode function without issue, but am trying to avoid doing so as I really only need to know this information once when this behavior tree is first ran.

Does OnBecomeRelevant not have access to this information? Or is there a different way of going about this?

Thank you for any help!
