Hi!
I would like the enemy NPC to detect the player when he is around and chase him. If the player is not around the next behaviour should be to stand idle for some time and than wander.
I have hard time figuring out how to revaluate the "Player in Sight" condition while still in "Wander behaviour" in the Behaviour tree.
In FSM we use transitions and we can check every ex frame if a condition is met or not.
How do I do that within the behaviour tree? For example when I do "Wander Behaviour" I return TaskStatus.Running like in the Writing new Action documentation :
Now I would like to revaluate the "Player In Sight" condition while the NPC is wandering but if I return TaskStatus.Running the only way to do it would be to copy/paste the code from "Player In Sight" into "Wander Behaviour" - which seems stupid since we already have this implemented as a separate Condition.
How do I revaluate the first sequence and if it is false return to "Wander behaviour" without having to "wait" to simulate the Idle behaviour?
I think that I didn't yet figured out the correct way to think in terms of the "behaviour tree" but than again the tutorial section only shows very basic examples so its hard for me to figure this out on my own.
I would appreciate any help!
Peter
I would like the enemy NPC to detect the player when he is around and chase him. If the player is not around the next behaviour should be to stand idle for some time and than wander.
I have hard time figuring out how to revaluate the "Player in Sight" condition while still in "Wander behaviour" in the Behaviour tree.
In FSM we use transitions and we can check every ex frame if a condition is met or not.
How do I do that within the behaviour tree? For example when I do "Wander Behaviour" I return TaskStatus.Running like in the Writing new Action documentation :
public override TaskStatus OnUpdate()
{
currentTime += Time.deltaTime;
if(currentTime >= wanderTime || currentSensor == null || pathBlocked)
{
enemyBrain.SetMovementInput(Vector2.zero);
return TaskStatus.Success;
}
return TaskStatus.Running;
}
Now I would like to revaluate the "Player In Sight" condition while the NPC is wandering but if I return TaskStatus.Running the only way to do it would be to copy/paste the code from "Player In Sight" into "Wander Behaviour" - which seems stupid since we already have this implemented as a separate Condition.
How do I revaluate the first sequence and if it is false return to "Wander behaviour" without having to "wait" to simulate the Idle behaviour?
I think that I didn't yet figured out the correct way to think in terms of the "behaviour tree" but than again the tutorial section only shows very basic examples so its hard for me to figure this out on my own.
I would appreciate any help!
Peter