# Behavior asset assigned from editor is null in c++ class

**URL:** <https://forums.unrealengine.com/t/behavior-asset-assigned-from-editor-is-null-in-c-class/318234>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 11, 2015, 8:01pm UTC](https://forums.unrealengine.com/t/behavior-asset-assigned-from-editor-is-null-in-c-class/318234 "2015-05-11T20:01:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [May 11, 2015, 8:01pm UTC](https://forums.unrealengine.com/t/behavior-asset-assigned-from-editor-is-null-in-c-class/318234/1 "2015-05-11T20:01:42Z")

</div>

Hi!

I have a property in c++ that should hold the behavior tree to use like this:

```
UPROPERTY(EditDefaultsOnly, Category = "MyAIController")
	UBehaviorTree *BTAsset;

```

I inherit the class from a blueprint and assign the `BTAsset` property a behavior tree from the editor. However when I run the code it’s null even though it should be assigned. Any ideas what may be causing this issue? Why is `BTAsset` null even though it looks like it’s assigned in the editor property. The behavior tree seems to work if I run it directly from blueprint.

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [May 11, 2015, 8:08pm UTC](https://forums.unrealengine.com/t/behavior-asset-assigned-from-editor-is-null-in-c-class/318234/2 "2015-05-11T20:08:25Z")

</div>

If it looks like assigned the it’s assigned 😃 The problem might be the “when” of your code. Properties like that are being set after class’ constructor runs, so if you need to use properties’ values you need to wait at least for `PostInitProperties` or `PostLoad`.

Let me know if that was the case.

Cheers,

–mieszko

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [May 12, 2015, 2:09pm UTC](https://forums.unrealengine.com/t/behavior-asset-assigned-from-editor-is-null-in-c-class/318234/3 "2015-05-12T14:09:53Z")

</div>

I forgot to mention that I use the asset in BeginPlay like this:

```
void AMyAIController::BeginPlay()
{
	Super::BeginPlay();
	
	RunBehaviorTree(BTAsset);
}

```

I checked the value after `PostInitProperties` and `PostLoad` but it’s still null.

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [May 12, 2015, 5:10pm UTC](https://forums.unrealengine.com/t/behavior-asset-assigned-from-editor-is-null-in-c-class/318234/4 "2015-05-12T17:10:33Z")

</div>

I’ve just tried it using 4.8 prev 1 build and was not able to repro what you’re experiencing. And I know we’re using this setup in most of our projects so if it didn’t work we’d know.

Would you mind posting a striped-down version of your project so that I can investigate your setup?

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [May 12, 2015, 7:53pm UTC](https://forums.unrealengine.com/t/behavior-asset-assigned-from-editor-is-null-in-c-class/318234/5 "2015-05-12T19:53:59Z")

</div>

Seems to be something specific to my project. Couldn’t reproduce this myself in another project were it worked perfectly. I will have to investigate this issue further. Is probably on my end then.

Thanks for the help!
