Page 1 of 1

Behavior Designer - Is Lua True

Posted: Fri Feb 18, 2022 9:12 pm
by halbey
Hello,

I am trying to build a behavior tree with an "Attack" which is conditional on "Is Lua True". I cannot find the right syntax to check the Lua variable.

I want the AI to attack only if the Lua variable (bool) is true.

E.g. the Lua variable => "player_alive" = true (default as set in the Dialogue Database / Variables)

How should I write the Lua Code in the Behavior Tree? I tried with "player_alive" or "Variable["player_s5duel"]", but it doesn't work.

I have attached the Lua bridge to the AI character

Thank you!

Re: Behavior Designer - Is Lua True

Posted: Fri Feb 18, 2022 10:12 pm
by Tony Li
Hi,

You shouldn't need the bridge for Is Lua True.

The syntax to check if the Dialogue System variable "player_alive" is true is:

Code: Select all

Variable["player_alive"] == true

Re: Behavior Designer - Is Lua True

Posted: Sun Feb 27, 2022 5:57 pm
by halbey
Hi Tony,

thank you for your reply. I tried using this syntax

Code: Select all

Variable["player_alive"] == true
in the Inspector / Lua Code section of the Behavior Designer Tree (see attached), but I get that the "Lua code is null or empty".

Could you confirm that my approach is correct?

1- I start with the variable "player_alive" = true (setup in the Dialogue database)
-> the AI should attack
2- if, conditional to some action, I set the variable to false in a script: DialogueLua.SetVariable("player_alive", false);
-> the AI should not attack

Re: Behavior Designer - Is Lua True

Posted: Sun Feb 27, 2022 7:41 pm
by Tony Li
Hmm, that error is strange, since I see that the Lua Code field has code. From everything you described, you're doing it correctly. Is the error maybe coming from a different behavior tree or a different task node?
Can you send a reproduction project to tony (at) pixelcrushers.com?

Re: Behavior Designer - Is Lua True

Posted: Mon Feb 28, 2022 7:26 pm
by halbey
Hi Tony,

I tried again and now it works. The only difference is that I wrote the code instead of just copy pasting...it doesnt make much sense but at least it looks fine

Thank you for your support!

Re: Behavior Designer - Is Lua True

Posted: Mon Feb 28, 2022 8:08 pm
by Tony Li
Very strange! Glad it's working now.