I’m evaluating possibility of nodecanvas in my project.
One thing that is very important to me is the way behavior tree is updating itself.
Can I control when it is going to be updated. For example I’m going to use repeater for update.
I could not find this info anywhere. Also there is info about update in fixed update, and normal update.
What is considered normal update ? MonoBehavior “void Update()” ?
What if I got some lag in fps and and my Time.deltaTime is going to be quite big will it update Behavior Tree less often ?
The perfect solution for me would be to have something like FixedUpdate but for BT.
Thanks for looking at NodeCanvas for your project.
By default, graphs (including BTs and FSMs) are updated automatically, but you have the control to manually update the graph if you want by code.
When done automatically, graphs are update from within a MonoBehaviour “manager” void Update.
With that said, if you create some custom Action Tasks that you want them updated in FixedUpdate, say for physics related things, there is a way of making these custom action tasks indeed update in a FixedUpdate loop for the duration that the action task is running. Otherwise, all action task execution is happening from within that original “normal” update of the graph. FixedUpdate in general should only really be used for when dealing with physics by the way, and certainly you wouldn’t want the whole tree to update in the physics loop, but rather only the actions that relate to the physics directly 🙂
Let me know if that answers your questions, or if you have any more questions at all.
Thanks 🙂
Can you point me to the documentation of manually updating BT.
To clarify things. Is OnUpdate of task getting called from BT updating or is it using unity3d Update directly even when I’m using custom BT updating ?
Why all the fuss. I personally think that AI should be deterministic, there is no determinism in Update method, I cannot accept situation where application is behaving differently depending on someone FPS.
This is why I will use FixedUpdate or Repeating. Also I don’t have to update it every frame it could be done every n-th FixedFrame for example.
Tasks are updating from within the BT update and not independently, unless you want to do so.
To make AI deterministic and anything really, FPS independent, you simply have to use Time.deltaTime where it is adequate, but it’s really your call how you want to handle this of course 🙂 FixedUpdate is really only there in Unity to be used with Physics :).
As for some code, from the next version, this is the only piece of code that is needed to manually update a BehaviourTree (owner) manually:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
publicclassExample:MonoBehaviour{
publicBehaviourTreeOwner BTOwner;
voidStart(){
//false autoUpdate, null callback
BTOwner.StartBehaviour(false,null);
}
voidUpdate(){
BTOwner.UpdateBehaviour();
}
}
Please let me know if you have any more questions.
Thank you.
I still got a problem with this. Even when I use BTOwner.UpdateBehaviour();
I should be able to pass dTime to it like this ” BTOwner.UpdateBehaviour(dTime) “.
For now it is assumed that UpdateBehaviour is updated inside MonoBehavior.Update so the user will use Time.deltaTime (my guess).
So I will have to store this dTime in some kind of variable making this solution quite hackish. Also if there are predefined behaviors they probably also use Time.deltaTime are they ?
Yes, all predefined tasks use Time.deltaTime, since the graphs are updated in MonoBehaviour.Update (or LateUpdate) 99% of the time.
I see what you are getting at though. I think that I could add what you ask. I will have to update all tasks to use graph.deltaTime, but that is not a problem, since I can see your suggestion being useful. 🙂
Let me know what you think.
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.