Hi, I just started working with behaviors in Uniity and I’m having some questions.
I’m trying to use sub-graphs to organize my behaviors but it seems to me that variables (without the shared activated) are actually shared between graphs that have the same subgraph, for example, if I have 2 enemies with the same behavior graph and subgraph, editing a variable in the subgraph shares the variable value between all the enemies.
Is that intended or am I doing the setup wrong?
My other question is about BlackboardAssets. The same is happening to me, variables are shared even with the “shared” disabled. Also, I tried accessing the BlackboardAsset from the graph in code but I don’t really know how to do it, I inspected the graph and its blackboard but the BlackboardAsset is not in there. Am I doing anything wrong? Maybe I should store that BlackboardAsset in a class too?
I’m not sure if these are stupid questions but thanks for the help anyway.
The example provided is a bit old and we now recommend to use BehaviorGraphAgent.GetVariable. Especially if you are trying to access a BlackboardVariable from a BlackboardAsset that is linked to a BehaviorGraph. This is because BehaviorGraphAgent.BlackboardReference is referring to the BehaviorGraph-specific blackboard. Using the GetVariable from the Agent will looks for BBV from any blackboard referenced by the agent’s graph instance.
Hope this makes sense.
That sounds like a bug, could you provide more details? Are you using Static or Dynamic subgraph? Which Blackboard Variable are you referring to?
If a blackboard variable is not shared, every agent should have their own instance of the variable.
Same applies for BlackboardAssets. Agent are creating a duplicate of each non-shared blackboard variables.
That was exactly what I was looking for, thank you so much!
Regarding the second matter:
I’m using a dynamic subgraph with a float, at the start of the execution I call the subgraph, run an action that prints the value of the float, makes it random and prints it again, and I have currently 2 enemies executing this sequence. the results are that the second enemy received the same value when the first one changed it.
But hard to pinpoint the cause from just the information provided. Could you share a screen of your graph, subgraph and script that randomize the float please?
It might be an issue related to the recent change to Agent Lifecycle, and if so it is probably already being worked on.
I tested dynamic subgraph and it seems like there are some new issues. I won’t have time to investigate right away, can you open a bug report with the information you provided on the thread please?