Using Master/Slave AIBrains
Last updated
Was this helpful?
Last updated
Was this helpful?
The Master/Slave system implements a set of methods to control AIBrains (set as Slaves) from other AIBrains (set as Masters) or other parts of the application through the Corgi/TopDown .
The two main actors involved in this system are:
Brain Master: not necessarily connected with a brain, it is used to send State change command events through dedicated channels
Brain Slave: this element listens for State change command events and forces the AIBrain behavior
The BrainMaster ability component lets you send state change commands to slave brains through a dedicated channel: usually this is achieved through an AIActionChangeAIBrainStateCommand but you can access the SendCommand method:
channel is used to filter who will receive and execute the command
newStateName is the state the AIBrain should transition in
target is the AIBrain target (if any)
The BrainSlave ability component is used to receive state change commands through a dedicated channel.
Whenever an event is received, the slave will try to change the AIBrain to the new state.
As an alternative, the state change can be also forced through the TransitionToState() method:
newStateName is the state the AIBrain should transition in
target is the AIBrain target (if any)
To use the Master/Slave communication system, you will have to create a Channel, that will be added to the slave channel list:
Select Create > The Bit Cave > MasterSlave > State Command Channel
Rename the newly created asset
Add it to your slave Channels list
Add the same channel to the master AIActionChangeAIBrainStateCommand component