Manual ticking with Fixed Update

KOKOStern

New member
I'm ticking the manager manually cause I wanted to have greater control over my Update function (I have a managed calls manager).

I have a physics cast task that I want ran on FixedUpdate and not on Update, but OnFixedUpdate never gets ran if you Tick manually. Is there a way to Tick the other update types or am I not getting something?

To be clear I switched back to Every Frame on the manager and the FixedUpdate gets called properly.

On the same subject of FixedUpdate: is there a way to 'finish' the task with just OnFixedUpdate? I don't need the update call and it's very awkward that I have to 'wait' for fixed update to happen (as update happens more often) and then finish the task on the update the next frame. Of course the tree will run on Update time, but on the specific task script I shouldn't need to have an Update function and just be able to tell the task it's done (TaskStatus =) some other way right?

Thank you,
 
I have a physics cast task that I want ran on FixedUpdate and not on Update, but OnFixedUpdate never gets ran if you Tick manually. Is there a way to Tick the other update types or am I not getting something?
If you run BehaviorManager.FixedUpdate it'll run the fixed update loop. The Tick method is the same as what is normally called by the BehaviorManager.Update loop.

On the same subject of FixedUpdate: is there a way to 'finish' the task with just OnFixedUpdate? I don't need the update call and it's very awkward that I have to 'wait' for fixed update to happen (as update happens more often) and then finish the task on the update the next frame. Of course the tree will run on Update time, but on the specific task script I shouldn't need to have an Update function and just be able to tell the task it's done (TaskStatus =) some other way right?
There's not unless you call BehaviorManager.Tick within a FixedUpdate loop. I'm not sure what results that would bring though. All of the tree traversal happens within the Tick method.
 
Alright cool.

Using BehaviorManager.Update and BehaviorManager.FixedUpdate in their appropriate functions instead of Tick() works. I would suggest updating the documentation on BehaviorManager to say this in some way?

About the second question, it leads to a very awkward:

Code:
        public override void OnStart()
        {
            _ranFixed = false;
        }

        public override void OnFixedUpdate()
        {
            _npcAreaCheck.TryCheckArea(_detectionLayers.Value, _detectionRadius.Value);
            _ranFixed = true;
        }

        public override TaskStatus OnUpdate()
        {
            if (_ranFixed)
            {
                return TaskStatus.Success;
            }
            return TaskStatus.Running;
        }

Is there a better way?
 
I was actually going to say that there's not a way to traverse the tree within FixedUpdate but then I thought of the Tick within FixedUpdate workaround so there's not a better way. The FixedUpdate method does not traverse the tree.
 
Does that mean every task (at least conditional and action) needs to have an Update method always?

Wouldn't it make sense to have some kind of variable that you can set, and if there's no Update method you just check that variable (on Update time of course) and return that? Something similar to Composite tasks executionStatus?

executionStatus is super useful. Just used it in a cooldown sequence task:

Code:
        public override void OnStart()
        {
            // Checking if we can run.
            if (!CooldownOver())
            {
                executionStatus = TaskStatus.Failure;
            }
        }
        public override void OnEnd()
        {
            // If we ran properly, we get the next timestamp.
            if (executionStatus == TaskStatus.Success)
            {
                _nextTimestamp = Time.time + _cdBetweenPickInSeconds;
            }

            // All of the children have run. Reset  variables.
            executionStatus = TaskStatus.Inactive;
            currentChildIndex = 0;
        }

This way it doesn't run if I just set it to failure (or just moves forward) and I can control it.
 
Wouldn't it make sense to have some kind of variable that you can set, and if there's no Update method you just check that variable (on Update time of course) and return that? Something similar to Composite tasks executionStatus?
I've actually thought about this somewhat recently and think that overall it would be a positive change to give you more control over when a task ends. The problem is that this would be a pretty major change to the API so I wouldn't want to make the change until Behavior Designer 2 (which is still awhile away).
 
Hey @Justin did anything ever come of this with respect to your current work on Behavior Designer 2? The reason I ask is that I'm trying to ensure determinism and I presume having behavior trees operate on Update instead of FixedUpdate could be problematic?
 
If you manually tick the behavior tree within FixedUpdate the OnUpdate method is executed during the FixedUpdate loop. This will allow you to have determinism for your tree.
 
Top