Throttle a conditional abort ?

patrick_l

New member
Hi,

I've run into an issue trying to throttle a conditional abort and looking for another way to handle it.

Basically I have a conditional task ("Should Avoid") that does a bit of processing to calculate an avoidance vector/position and then set a Variable for use in the next task. Since I don't want it to run each tick I want to only run it every x seconds since the last time it was run. I have the following code in the OnUpdate:


C#:
    public override TaskStatus OnUpdate()
    {
        if (Time.time - m_LastDelayTime < m_DelayTime.Value)
        {
            return TaskStatus.Failure;
        }

        m_LastDelayTime = Time.time;
        return TaskStatus.Success;
    }

The problem is the whole Task seems to get re-evaluated after it triggers the abort and stop the lower priority tasks so when it run again it returns Failure since it set the `m_LastDelayTime ` in the first call.

Is there a way to use a conditional abort with a throttle like this? How else could this be setup?

Thanks
Patrick
 

Attachments

  • avoid_bt.png
    avoid_bt.png
    80.6 KB · Views: 3
Your logic is the best method - there isn't a way to tick an individual task.
 
Hmm. Maybe I didn't explain the issue well since what I have in my example doesn't work. The Avoid Task never runs.

Either way I found a solution which was to create a standalone ThrottleTime task which uses the same logic as above but m_LastDelayTime is a global variable which I only update in the next step using a 'Get Time' Task
 
Top