# 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:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Susp\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Susp\_1](https://forums.unrealengine.com/u/Susp_1)\
**Post date:** [December 6, 2023, 7:12pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/1 "2023-12-06T19:12:19Z")

</div>

When I close unreal engine and then open it back up all of the variables reset themselves to the point where I have to go into each of the BT’s and reset all of the values to what it should be. This has to be some sort of bug. I know that I have set things up properly as it has worked in the past when I have changed nothing about it, do I seriously have to create a brand new project to fix it?

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [December 6, 2023, 7:40pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/2 "2023-12-06T19:40:32Z")

</div>

Hey @Susp_1!

So the default values should be set in the Blackboard attached to the BT. Go ahead and check those default values! When reinitialized the BB defaults will take priority.

Hope it’s that simple of a fix! Let us know how it goes!

---

<div class="post-metadata">

**Author:** ![Susp\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Susp\_1](https://forums.unrealengine.com/u/Susp_1)\
**Post date:** [December 6, 2023, 7:46pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/3 "2023-12-06T19:46:09Z")

</div>

I wish it was that easy, it’s not that the default values are different it happens in a task. For example, you have SomeTask, in SomeTask you take in a bool, and in the blackboard there is a bool called SomeBool, when I save the editor and the task is set to use SomeBool, then open the editor again, SomeTask is using SelfActor, even though I had set it to use SomeBool

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [December 6, 2023, 10:04pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/4 "2023-12-06T22:04:30Z")

</div>

I found a few forum topics that touch on this, with few solutions, but try this! It seems like it’s been an issue with others as well, throughout the years.

It looks like you may have extra processes running for UE. Try restarting your PC, open UE, go straight to the BT, change a variable to the correct one, save, close, reopen the project and see if that works!

> [@Behavior Tree Not Saving](https://forums.unrealengine.com/t/behavior-tree-not-saving/104188):
>
> I was trying to fix a bug for the longest time and figured out that the reason I haven’t fixed it yet is because my changes were not being saved… I have a blackboard variable that is unused. I have a service in a selector node that has the wrong variable linked. When I remove the blackboard variable and change the service node’s variable the proper one and hit save, changes are not made in game or in my files. It looks like they were made in the editor but if I close the editor and reload it…

---

<div class="post-metadata">

**Author:** ![Susp\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Susp\_1](https://forums.unrealengine.com/u/Susp_1)\
**Post date:** [December 6, 2023, 10:23pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/5 "2023-12-06T22:23:45Z")

</div>

I just tried this, unfortunately it did not help. I also updated Unreal Engine, I then verified, I uninstalled and then reinstalled, nothing has helped. How can I help you help me? What do I need to provide you with?

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [December 6, 2023, 10:57pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/6 "2023-12-06T22:57:32Z")

</div>

I personally would just roll back to an earlier version, and try that. Do you have backups?

At the risk of sounding like a workplace safety video, you should always back up your project as often as possible. I hate to say it, but while I was able to find 3 or 4 threads where someone else is having this issue, nobody really has any solutions other than the one thread I found for you (I even checked other forum sites).

This may be something you need to fill out the bug reporting form (located in the menu on the main page of the Editor, OR at [Unreal Engine Community](https://epicsupport.force.com/unrealengine/s/)) and roll back to an earlier date. ☹

Edit: One other thing that came to mind: Are you altering the custom BTTask at the source for the inputs and saving it? Or just changing it in the BT?

---

<div class="post-metadata">

**Author:** ![Susp\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Susp\_1](https://forums.unrealengine.com/u/Susp_1)\
**Post date:** [December 11, 2023, 9:35pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/7 "2023-12-11T21:35:32Z")

</div>

I’m changing it in the BT, then saving, closing the editor, then opening the editor again, opening the same BT and everything that I had set is now set to SelfActor

---

<div class="post-metadata">

**Author:** ![Stratego](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/stratego/32/564611_2.png) [@Stratego](https://forums.unrealengine.com/u/Stratego)\
**Post date:** [May 31, 2024, 11:01pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/8 "2024-05-31T23:01:00Z")

</div>

I am having this issue on UE 5.4.1

I’ve also had this issue in the past, I believe 5.3

I posted about is and never got a fix.

---

<div class="post-metadata">

**Author:** ![FeliciKing](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FeliciKing](https://forums.unrealengine.com/u/FeliciKing)\
**Post date:** [June 1, 2024, 4:42am UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/11 "2024-06-01T04:42:47Z")

</div>

You can review that

---

<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:17pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/12 "2024-06-09T13:17:38Z")

</div>

I am having this exact same issue! My Behavior Tree Tasks have their variables resetting when I close UE and launch it again.

UE 5.4.2. I followed the tutorial here: [https://www.youtube.com/watch?v=-t3PbGRazKg](https://www.youtube.com/watch?v=-t3PbGRazKg)

I have recreated the Behavior Tree and its Blackboard from scratch, and the exact same thing happens on this behaviour tree.

Moreover, whenever I fix the values (_doing nothing else after the launch of the editor_) and view the changes in Revision Control, the diff has nothing to do with the broken BTT!

This is the diff that UE detects after fixing the variable values, and please note, neither of these tasks are the ones I changed, and their values were fine:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/e/c/bec0caf62a17601111937b9e42d18774efec13ea.png)

This is the task (there is a second instance of it in the BT) that always has its `Movement Speed` set to `Idle` (instead of what you see here). Changing this value from `Idle` → `Movement Speed` resulted in the diff above! 🤯

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/6/3/f63ae293bf117ae1fa8c6d6ccc496c99996208c6.png)

This is breaking any ability to even follow a tutorial 😃 I will try next by creating a new Behavior Tree Task to see if the current one is corrupted somehow?

---

<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.

---

<div class="post-metadata">

**Author:** ![CaptainDasLamm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CaptainDasLamm](https://forums.unrealengine.com/u/CaptainDasLamm)\
**Post date:** [September 10, 2024, 6:47pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/14 "2024-09-10T18:47:32Z")

</div>

Did you try for the tasks in question to go file-\>refresh all nodes and compile again?

 ![Screenshot_280](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/b/c0b04e9a48e23d748b1de500a610635cb64407a9.png)

---

<div class="post-metadata">

**Author:** ![RIKASHU\_23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RIKASHU\_23](https://forums.unrealengine.com/u/RIKASHU_23)\
**Post date:** [March 21, 2025, 4:45am UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/15 "2025-03-21T04:45:24Z")

</div>

Just adding my solution for this problem, I changed the **Blackboard key selector variable** inside my task to expose on spawn and that seemed to do the trick. Figured as (in my case) having duplicates of a task inside my behavieour tree might return a clash, deciding which variable to take in everytime engine gets restarted. So I got to the conclusion that just setting the “Expose on spawn” option would split these tasks. Also if this was not a solution for you, there are a few work arounds like setting and changing this value with an event inside your AI Controller and then call it inside your task.

 ![SS1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/5/4/7540efd22fb393f48c629b9791990fa2c2993959.png)

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [March 21, 2025, 10:57pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/16 "2025-03-21T22:57:14Z")

</div>

Let us know if any of these worked, @Susp_1!

Otherwise I’ll mark @RIKASHU_23’s answer as the solution so we can get this closed up, it seems very usable for most use cases on this problem!

---

<div class="post-metadata">

**Author:** ![JoseFabregat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JoseFabregat](https://forums.unrealengine.com/u/JoseFabregat)\
**Post date:** [March 31, 2025, 2:52pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/17 "2025-03-31T14:52:56Z")

</div>

I had the same issue and I have solved it adding a new dummy variable to the behavior tree task, assigning again in the behavior tree to the blackboard key, then saving and closing the editor. That did the trick and I could remove the dummy variable. My guess is serialization issue and that anything that tricks UE into serializing it again will solve the issue.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [April 30, 2025, 2:53pm UTC](https://forums.unrealengine.com/t/why-does-my-behaviour-tree-reset-its-task-variables/1498947/18 "2025-04-30T14:53:42Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
