How to save and load behavior trees?

Sicne you sent me a message I figured Id answer here instead for others to see.

Its really hard to say what will work for your game. As for me I have a really complex game with hundreds of nodes and a ton of AI.
What I do is I save all SharedVariables Im interested in.

When I load I first initialize all variables then setup all references using saved guids. After that I enable my behaviour trees. There aare several ways you could go from here. I used to just let it find its way back to where it was on save which worked fine but would give you a second of units looking a bit lost when starting up.

What I do now is for each external behaviour tree (All my logic is seperated into external behaviour trees, for example baker, blacksmith, miner etc). Each of these trees will start by checking if this is a load, and if it is, it will set it self up using saved states, then go into the main repeater for that external tree.

Its a lot of work but it also gives you a lot of control. And thanks to external trees it doesnt get too messy. Tbh I doubt there is any way Justin can write a save/load that will work for 100% of cases, so managing it urself is not a bad idea.
 
Sicne you sent me a message I figured Id answer here instead for others to see.

Its really hard to say what will work for your game. As for me I have a really complex game with hundreds of nodes and a ton of AI.
What I do is I save all SharedVariables Im interested in.

When I load I first initialize all variables then setup all references using saved guids. After that I enable my behaviour trees. There aare several ways you could go from here. I used to just let it find its way back to where it was on save which worked fine but would give you a second of units looking a bit lost when starting up.

What I do now is for each external behaviour tree (All my logic is seperated into external behaviour trees, for example baker, blacksmith, miner etc). Each of these trees will start by checking if this is a load, and if it is, it will set it self up using saved states, then go into the main repeater for that external tree.

Its a lot of work but it also gives you a lot of control. And thanks to external trees it doesnt get too messy. Tbh I doubt there is any way Justin can write a save/load that will work for 100% of cases, so managing it urself is not a bad idea.
Thanks for the extensive reply. Would you please be able to share one simpler External Behavior (a picture of the whole tree) and just explain a bit more how it all works? If I understand correctly, you let the tree know that it's supposed to be loading (by using a bool let's say), then you assign all the Shared Variables you need, but which code serves to guide the tree to the node where it last left off? How is it structured?

I also didn't really understand the difference between you first approach and the one you're doing now with the external behaviors, so I'd appreciate if you could put a bit more clarity on that too.

Any information at all is super helpful. Thank you!
 
Thanks for the extensive reply. Would you please be able to share one simpler External Behavior (a picture of the whole tree) and just explain a bit more how it all works? If I understand correctly, you let the tree know that it's supposed to be loading (by using a bool let's say), then you assign all the Shared Variables you need, but which code serves to guide the tree to the node where it last left off? How is it structured?

I also didn't really understand the difference between you first approach and the one you're doing now with the external behaviors, so I'd appreciate if you could put a bit more clarity on that too.

Any information at all is super helpful. Thank you!

Unfortunately that information is all going to depend on your game and your tree.
 
Unfortunately that information is all going to depend on your game and your tree.
I think that's quite obvious. I learn best by example which is why I asked you if you could share a concrete example of one of the simpler trees you're saving this way, but you just seemed to ignore it. If you don't want to share it or can't share it, I understand.
 
No work on this yet. I am still holding out hope for a DOTS version now that Unity has released a somewhat roadmap of v 0.50 and 1.0.
 
No work on this yet. I am still holding out hope for a DOTS version now that Unity has released a somewhat roadmap of v 0.50 and 1.0.
Any news on this now that Unity has released quite a few updates on DOTS and its future is more certain?
 
We are releasing version 3 of our character controllers and then my main focus will be version 2 of Behavior Designer. I'm glad that DOTS has started to mature.
 
We are releasing version 3 of our character controllers and then my main focus will be version 2 of Behavior Designer. I'm glad that DOTS has started to mature.
Hi! Now that Ultimate Character Controller v3 has been released, is it safe to assume work will be started on version 2 of BD fairly soon? I'm still really excited and hoping for the saving/loading functionality.
 
Version 3 is out (finally!) but there's still some integrations and add-ons that need to be updated. I am expecting to be able to get back to Behavior Designer fulltime at the start of next year.
 
It's been a few years now, but we're still waiting for the built-in save/load method. I hope this will appear in the first version and will not be a paid update.
 
Hey Folks a couple of questions:

1. Do you guys have any code snippets you are willing to share on how you go about implementing this. It's a lot to ask of you all but I think it would help reduce the cost of sifting through code in the BehaviourManager, etc to restore fields, state. I feel this is a common use case so it would be super useful to people. There is no documentation on how to do this and would really help others who are trying to implement this. I would be happy to contribute to this but I'm not looking to implement save/load in my RTS type game for a little while longer. If no one posts snippets or more code level findings/best practices, I'll post up some stuff when I get around to this when I get around to implementing save/load on my project.

2. I'm two years in on a big build here and as I move away from the demo of the game and into full production mode, I'm t trying de-risk big technical challenges of my game. Save and load is probably the second biggest technical risk I have at the moment. My question is how feasible was your save a loading of BT states? As there is uncertainty on if we can achieve this full, what was an approximate time you spent implementing this? Did you guys have good results in saving and loading of behaviour tree/manage's runtime state?

3. @Justin - Will there be a version of BD 1.X.X with a save feature or API in the next 1.5 years or any other major plans to BD 1.X.X? just trying to understand the realistic nature of this so I can plan/scope accordingly.


Thanks everyone and have a nice day!
 
3. @Justin - Will there be a version of BD 1.X.X with a save feature or API in the next 1.5 years or any other major plans to BD 1.X.X? just trying to understand the realistic nature of this so I can plan/scope accordingly.
Behavior Designer 2 should be released within that timeframe, and I plan on having it include a save/load feature. With that said, the Behavior Designer 2 API is completely different from version 1 so I don't think that I will be able to back port it.
 
Top