Hey there, I've a question about manually controlling behaviour tree update. In the attached screen shot is a behaviour. Pretty simple:
The issue is that the MoveAI action is bespoke and contains a coroutine, so when the behaviour is executed via a 'tick', MoveAI runs and yields (task return status returns 'isRunning') which ends the behaviour for that tick.
This makes sense, but I'm after some sort of mechanism that would allow the behaviour to be ran until it returns either a success or failure taskstatus return type. I'm thinking this could be achieved by how it's called - perhaps there's a way I can test to see if the taskstatus return type is running, but the behaviour tree isn't executing and then trigger another tick?
Thanks for any help!
Ant
- In the left hand sequence, it tests to see if the enemy is visible. If so, shoot!
- In the right hand sequence, move to a position where the AI can see the enemy, then shoot them
C#:
IEnumerator StartBehaviourTree()
{
if (BehaviorManager.instance == null) Debug.LogError("Behaviour tree instance is null");
BehaviorManager.instance.Tick(m_behaviourTree);
while (m_behaviourTree.ExecutionStatus == BehaviorDesigner.Runtime.Tasks.TaskStatus.Running)
{
yield return null;
}
// For the moment we'll just give AI one move
UseActionPoints(2);
}
The issue is that the MoveAI action is bespoke and contains a coroutine, so when the behaviour is executed via a 'tick', MoveAI runs and yields (task return status returns 'isRunning') which ends the behaviour for that tick.
This makes sense, but I'm after some sort of mechanism that would allow the behaviour to be ran until it returns either a success or failure taskstatus return type. I'm thinking this could be achieved by how it's called - perhaps there's a way I can test to see if the taskstatus return type is running, but the behaviour tree isn't executing and then trigger another tick?
Thanks for any help!
Ant