I sometimes want to break the “Running” behaviour and force reevaluation of a Tree. For instance my Enemy is performing a complex Dashing Attack sequence and is stunned suddenly. I want him to break free from this sequence that was Running and I somehow don’t want to add new conditions to the sequence (and make it Dynamic).
I did some early test with reseting a tree like this:
‘this.gameObject.GetComponent<BehaviourTreeOwner> ().BT.primeNode.ResetNode ();
It worked fine on simple tests, but now in more complex BTs it doesn’t. I’m launching the tree reevaluation inside a forever repeater running in parallel with Wait (as in this discussion: http://nodecanvas.com/forums/topic/running-action-composed-of-few-smaller-actions/). Maybe that’s somehow a problem it doesn’t work?
Anyway I would be glad to know the “right” Node Canvas way to do it :).
Sorry for late reply.
Breaking out of Running behaviours can be done with either of the following ways, but all al depended on a condition:
– Use of Dynamic Sequencer/Selector with a condition child.
– Use of Interruptor Decorator.
– Use of Dynamic Accessor Decorator.
Reseting the root node of the BT this way, may work but it’s not thoroughly tested. Especialy using it under a Repeater 🙂
Why wouldn’t you want to use a condition since in practise, you will reset the tree if something happens?
If the reason is not to clutter the variables, you can use the ‘Check Event’ condition and send an event to the BT. So for example you can use an Interruptor with a Check Event Condition (“stunned”) and when the enemy is stunned, you can send the event by any means, like for example with the ‘SendEvent’ action or by code.
I’ll check the check event condition – It can be something I need.
My line of thinking was to adapt Node Canvas slowly – I mostly try to do things as I did without behaviour trees and adapt slowly as I go. So for stunning enemies I imagined checking collisions in a classic way, by implementing OnCollisionEnter and processing everything there. Instead of having heavy logic in BTs (that I don’t fully understand yet), I wanted to use some kind of “Break BT execution” function that I will be more comfortable with.
What I liked in Node Canvas from the beginning was that it’s not about “making games without programming”, but it can be used as an extension of my normal programming workflow.
I can’t say Im exactly sure what you are after, but if you want to kind of restart the BT resting all node status, you can do:
owner.StopBehaviour();
owner.StartBehaviour();
With that said, I really think that a valid way of what you want is to use events and Interruptors or Accessors.
So you could create your MonoBehaviour and OnCollisionEnter of it, call SendEvent on the BehaviourTreeOwner.
In turn your CheckEvent condition tasks assinged on any Inrruptor or Accessor will respond to that event and interrupt the child node.
Let me know if you want a image of what Im suggesting here 🙂
What I wanted to aviod is adding nodes on every running behaviour, so I don’t want adding Interruptors everywhere (or make all sequencers dynamic) – that didn’t seem right. Generally what I was trying to achieve from code is pictured here in a tree form: http://imgur.com/NHYMNnj. An Interruptor on top of the whole tree just for reseting.
It works fine so far, as StopBehaviour() – StartBehaviour() tree reseting, but I’ll have to run tests with my proper AI and see if it works there.
Author
Posts
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.