Timed Conditional Aborts

volak

New member
I have a behavior like so

1225


The idea is for the object to wander around UNTIL it can see object, takes damage, or hears object.

The conditional abort feature makes this possible - because the infinite task Wander is interrupted if one of the 3 previous tasks return success. However the 3 conditions dont need to be reevaluated every frame and it actually kills performance with ~50 agents on the screen....

Can you add a new field on composite-type tasks to only abort every X seconds? Default being every frame
 
added a new LimitEvaluation workaround for now

C#:
[TaskDescription("Only reevaluates a task if a certain amount of time has passed")]
    [TaskIcon("{SkinColor}UntilSuccessIcon.png")]
    public class LimitEvaluation : Decorator
    {
        [Tooltip("Seconds to wait in between eveluations")]
        public SharedInt wait = 1;

        // The status of the child after it has finished running.
        private TaskStatus executionStatus = TaskStatus.Inactive;
        
        private float _nextExecution = 0f;


        public override bool CanExecute()
        {
            var currentTime = Time.time;

            // Continue executing until we've reached the count or the child task returned failure and we should stop on a failure.
            return (currentTime >= _nextExecution) && (executionStatus == TaskStatus.Failure || executionStatus == TaskStatus.Inactive);
        }


        public override void OnChildExecuted(TaskStatus childStatus)
        {
            // Update the execution status after a child has finished running.
            executionStatus = childStatus;
            _nextExecution = Time.time + wait.Value;
        }

        public override void OnEnd()
        {
            // Reset the execution status back to its starting values.
            executionStatus = TaskStatus.Inactive;
        }
    }
 
Top