When ticked, a priority selector will query the agent through its SelectTopPriority
method for the highest priority of its outgoing connections. The priority selector will then tick the connection corresponding to the returned index ID and its return value is passed on. If the ticked connection returns Running
, then the priority selector will not requery priority on next tick. If a priority query returns the Unknown
priority ID or an ID outside the queried set, the priority selector will return Failure
.
So let's create a tree as shown in the following figure with a priority selector and three actions, Eat, Sleep, and Play.
It's important to note that the orders of output connections are important, as their index values will be used to reference from the script. So, in this sample connection index, the eat action would be 0
, sleep would be 1
, and play would be 2
. And our SelectTopPrioirty
method is implemented as follows:
private bool isHungry = true; private...