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:
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
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