Closed madeleineostoja closed 8 months ago
Try adding a call to update_current_behaviour()
to your AI agent, after you have the call to evaluate_options()
, for example:
$UtilityAIAgent.evalute_options(delta)
$UtilityAIAgent.update_current_behaviour()
If you have only a single action for each behaviour, then you can just use the Behaviour Changed signal and it is enough to call the evaluate_options()
method to choose between behaviours.
And thank you for asking, I'll add some tutorials to clarify these details with examples!
Gotcha, thanks! And I should still be setting is_finished on actions even if there’s only one per behavior?
In general, yes.
Setting is_finished=true is telling the AI agent that what ever you were doing with the action is now done and that it is OK to go to the next action. Or if this was the last (or only) action for the Behaviour, then it is OK to check for another Behaviour.
The ”Can be interrupted” property of the Behaviours has an effect on this. By default it is currently true, which means that the evaluate_options() call can check if some other Behaviour has gotten a better score than the current one even if the current one still is not finished with its actions. If you set ”Can be interrupted” to false, evaluate_options() will not check the other behaviours until the current Behaviour is finished with its actions.
Having a habit of setting is_finished=true makes sure everything works with more than one action and when the ”Can be interrupted” property needs to be set to false for some Behaviour.
Ahh okay that makes sense, thanks! For my use case most behaviors should probably not be interruptible by the agents own ai (attacking, dodging, etc) so I’ll be sure to update that and set action states accordingly
I might be using it wrong, but I have actions setup for each of my behaviors and attaching a listener to the
action_changed
signal on the ai agent gets called when the behavior changes, but theaction_node
argument to the signal is always null, so I can't check forname
and execute the appropriate code.Should I be using
behavior_changed
instead? Seems odd if I have to updateis_finished
etc on actions themselves