# Why does my behaviour tree reset its task variables

**URL:** <https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [December 6, 2023, 7:12pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947 "2023-12-06T19:12:19Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![mrusiniak](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mrusiniak](https://forums.unrealengine.com/u/mrusiniak)\
**Post date:** [June 9, 2024, 1:29pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/13 "2024-06-09T13:29:40Z")

</div>

Collecting other instances of this problem:

> [@Behavior Tree task bug? Blackboard Key Selector variable default "None" value being overridden in editor](https://forums.unrealengine.com/t/behavior-tree-task-bug-blackboard-key-selector-variable-default-none-value-being-overridden-in-editor/1809930):
>
> Hi all, I’m experiencing what appears to be a bug with BT tasks in 5.3.2 and am looking for confirmation and/or potential workarounds. For me the behavior happens with any task that has an instance-editable variable of type Blackboard Key Selector. Default value of the variable is set as “None” in the details tab of the task blueprint, however when the task is implemented in a behavior tree the editor continually overrides the variable from “None” to the first entry in my blackboard key list. C…

[https://www.reddit.com/r/unrealengine/comments/15kzt1l/why\_does\_my\_behaviour\_tree\_reset\_the\_blackboard/](https://www.reddit.com/r/unrealengine/comments/15kzt1l/why_does_my_behaviour_tree_reset_the_blackboard/)

> <https://stackoverflow.com/questions/76680197/behavior-tree-loses-references-to-blackboard-variables-on-editor-restart-ue-5-1>

> [@Behavior tree changes values when I open the editor.](https://forums.unrealengine.com/t/behavior-tree-changes-values-when-i-open-the-editor/754513):
>
> Hi, I have a behavior tree with values like TargetLocation and TargetAactor. When I reopen the editor the values are all set to SelfActor (the default value when creating a BB) I thought it was a 5.03 bug but its still doing it sometimes on 5.1

There is no apparent resolution. My temporary workaround will be to create a function per-variable-value I would have used (so `BTT_SetMovementSpeed_Walking` and `BTT_SetMovementSpeed_Sprinting`). This should not use variables in BTTs.

When trying to do that, it shows that UE5 is treating these Tasks as some sort of persistent value. This forum post describes this phenomenon: [Variables in Behaviour Tree task](https://forums.unrealengine.com/t/variables-in-behaviour-tree-task/387996). What I mean is that until I restart the editor, I will see the variables showing up in the Behavior Tree `Details` panel, even though the variables were deleted from the BTT and the BTT was compiled + saved!

I can confirm that flattening the variable options I’d like to use into individual functions works around this bug, but that is super super annoying and won’t scale for anything beyond simple enums.

---

_[View the full topic](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947)._
