Setting blackboard values in BehaviorTree Task and retrieving it results in inconsistent output

Hello all,

I am trying to set a value from BehaviorTree Task and output the result immediately in another BehaviorTree Task but the value set in blackboard and the value printed is inconsistent.

I am using Unreal Engine 5.4.

Behavior Tree:
image

Blackboard:
image

BTT_InitValue:

BTT_DebugPrint:

In BTT_InitValue, I get a random actor of class “BP_ObjectTest” and set the object in BB as “ObjectKey”. I also retrieved from BP_ObjectTest a variable called “FloatVal” and set the value in BB as “FloatKey”.

I create 2 child objects from class BP_ObjectTest:

  • BP_ObjectTest1 with FloatKey value 0.5
  • BP_ObjectTest2 with FloatKey value 1.5

In the level I place 2 objects:

  • 1 BP_ObjectTest1
  • 1 BP_ObjectTest2

My result expected from the behavior tree is the following:

  • BTT_InitValue set the object + FloatKey value in Blackboard
  • BTT_DebugPrint display the object + FloatKey from the blackboard
    As it is a sequence execution, I expect that the BTT_DebugPrint always displays values set in BTT_InitValue.

When executing it is not the case every time, below are logs of execution:

LogBlueprintUserMessages: [BTT_InitValue_C_0] Object:BP_ObjectTest2 |Float: 1.5
LogBlueprintUserMessages: [BTT_DebugPrint_C_0] DEBUG|||| Object: BP_ObjectTest2 | Float:0.5
LogBlueprintUserMessages: [BTT_InitValue_C_0] Object:BP_ObjectTest2 |Float: 1.5
LogBlueprintUserMessages: [BTT_DebugPrint_C_0] DEBUG|||| Object: BP_ObjectTest1 | Float:0.5
LogBlueprintUserMessages: [BTT_InitValue_C_0] Object:BP_ObjectTest1 |Float: 0.5
LogBlueprintUserMessages: [BTT_DebugPrint_C_0] DEBUG|||| Object: BP_ObjectTest2 | Float:1.5
LogBlueprintUserMessages: [BTT_InitValue_C_0] Object:BP_ObjectTest2 |Float: 1.5
LogBlueprintUserMessages: [BTT_DebugPrint_C_0] DEBUG|||| Object: BP_ObjectTest1 | Float:1.5

Those logs are generated after clicking on “Play this level” so Blackboard values are invalid before the BTT_InitValue.

Do you have any idea why the BTT_InitValue and BTT_DebugPrint are not synchronized in terms of Blackboard values?

Thanks in advance for any help :slight_smile:

Ok I got it, when using the random node in the BTT_InitValue, each usage of the object output is random so if you want to use the same object for different actions, you need to create a dedicated variable and use it.

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