I need to create an AI system for my project. My AI bots need to get Alarm state when they see a fire or smoke and run toward an exit. I encounter two problems:
My BT starts with a Selector which checks the presence of fire and sets the states and the exits. A route to a sequence with blackboard based condition checks the Idle State and sets the behavior of the bots to idle (low speed, wandering etc). When my bots see the fire they switch their state to Alarm and the other route is selected which is a sequence that sets the Alarm conditions and force the bots to run toward an exit.
The problem is that whenever the bots start to run toward an exit and they can’t see the fire anymore, they forget its presence and start to wander around… how can I stop the behavior tree to return to the Idle state and remain permanently to Alarm state (in other word how can they stuck to the left branch of the tree after its activation)? I tried abort and lower priority but in vain.
Some of my bots are spawn in location where the fire or smoke is between them and the exit. They walk on the fire and are getting killed. Is there any tip on how can I force my bots to avoid fire or smoke during their movement toward an exit?
When they first become alarmed, you can simply set a Boolean to true in your blackboard, and your left/idle branch is gated by that boolean (Blackboard condition) so it will never return to that branch until you set the boolean to false manually. You can create a simple BTTask that changes that boolean to true and have it execute at the start of your Alarmed branch. Then it’s up to you when you want to turn it off.
Look at the documentation for Nav Modifiers. They create holes or more expensive navmesh areas that the AI will have to or try to avoid.
Do you propose to create a boolean key in my blackboard that will be altered (true or false). This bollean with be set as a condition in my left blackboard (Idle). The value will be changed by a Task connect to my left brance (I think far left in order to be executed first) on an ai execute event. Am I right?
The problem is that I need to allow some of the bots to enter the area of a fire and smoke in extreme situations (trapped, confused, forced etc). I need a way to avoid the hazard and search a route around it.
I think your suggestion is right. I set a bool on my basic service at the top of my tree to as a false (Idle). When the Alarm branch of the tree is executed, the bollean changes to true and the left branch blackboard (set to not set) is locked and the behavior cannot return to the previous state! Thank you so much!
If there are any suggestions on the other part they will be appreciated.
For number 2: this maybe over kill, but you could use EQS (Environment Query System).
With this, you can tell the pawn what actors to avoid and have them move away from the perceived danger(the actor).
Read as much of EQS as possible, because it can be hard to understand.
EQS is overcomplicated for that kind of functionality. Nav Mesh Modifiers exist for the purpose of making your AI path around objects. You could just make the fire/smoke area really expensive to path through with Nav Modifiers (instead of completely impassable), that way they would only take that path if there is no other way through.
Can I attach somehow the increased Nav Mesh Modifier to certain blueprint? the areas of fire are spawn by click events or random events so I need to make them be costfull. Thanks for the replies!