0
Answered

Check condition in behavior

mcyp 3 months ago in Behavior updated by Marti (Lead Developer) 3 months ago 4

Hello,

I came across a particular problem and so far I've been unable to resolve it by myself.


So, I have 2 NPCs with 2 different behavior trees. Let's call one NPC Bartender and the other Customer. Customer has a boolean which when true means he wants to take an order. Bartender waits until this boolean turns true and only then moves to the customer. The problem is, I can't seem to make the boolean which, through the Blackboard, is a local variable of Customer, visible to the Bartender. 

I'm trying to make this work through Bartender's Behavior and in the part "Use Conditions" I'm using condition "Variable Bool" where you should be able to compare the boolean with a value but since the boolean isn't visible for the Bartender, I cannot do so. 

Is there a way to make this work? Right now there's not enough documentation for behavior and so I'm forced to ask here. 

Unity version:
2019.4.0f
Game Creator version:
1.1.9
GOOD, I'M SATISFIED
Satisfaction mark by mcyp 3 months ago

Can you make the bool a global variable and use that?

Sure, that's possible but I didn't want to use that. Nevertheless, I managed to resolve my problem through scene objects, though I'm not sure if it's a correct and effective solution.

Can you please explain how you got it working? It may help others who have the same question. 

Answered

Blackboard variables are normal Local Variables under the hood. You should be able to reference the game object with the "Behavior" component in your scene and type the name of that variable.

On another note, remember that you can access another game object's variables using nested access.