Forums › 💬 NodeCanvas › ⚙️ Support › Problem with getting and saving variables from other agents › Reply To: Problem with getting and saving variables from other agents
Hello and thanks for your feedback. I am glad you like NodeCanvas.
AgentOverride decorator, will simply change the “target object” which will execute the rest of the tasks in the nodes bellow that decorator. It is exactly the same as manually going into each of those task bellow, and -by checking the checkbox- override the agent so that it’s not using “Self”, but rather some other agent provided, through a variable or a direct assignment.
Iterator is really different that AgentOverride and does not have any immediate relation. The Iterator decorator, will iterate a list for each of each elements, and for each of those elements, A) save that element in a variable and B) execute the decorated node.
Regarding setting a variable of another agent, the “Set Other Variable” tasks is indeed what you should be using if you want to do it visually (no coding). Just make sure to select the correct type of the variable you want to set with the relevant button found within the inspector of that task, as well as set the target Blackboard of which you want to set the variable to, by “overriding the target agent”.
[attachment file=”SetOtherBlackboardVariable.png”]
As you see above, I have override the target (by checking the checkbox) so that it’s not using “Self”, but rather a spececific Blackboard reference that I’ve assigned. In this case, the Blackboard of “GameObject2” (just drag and drop the gameobject). You could of course also use a variable instead of direct assignment if so desired.
Then for the variable name I want to set, I used “TargetVariableName”, while for it’s new value, I linked a GameObject variable type named “TriggerTarget”.
The “TriggerTarget” variable, was previously set by the CheckTrigger condition task:
[attachment file=”CheckTrigger.png”]
And this is the BT as an example:
[attachment file=”BT.png”]
As far as setting a blackboard variable from code, it can be done with using Blackboard.GetValue
and Blackboard.SetValue
methods, as I explained in your other post [HERE] 🙂
Let me know if the above help, or if you still encounter any troubles.
Thanks again!