Reply To: Saving and loading Behavior Trees

NodeCanvas Forums Support Saving and loading Behavior Trees Reply To: Saving and loading Behavior Trees



Saving the whole state of a graph is not supported. There are technical reasons not to, but I also believe that allowing to save the game at any given time is not ideal, hence why most games save only at some sort of check points (but that is of course not a defacto). Saving Blackboard variables is supported however, which depending on how the tree is designed (in conjunction with other non-variable conditions), it may become a way of saving a tree state and making the tree flow to the state it was, based on the evaluation of the conditions.

There is a way to make a node the “Start” node of the graph through code as well (by setting the ‘graph. primeNode’ property), which might work for your use case of resuming from a specific node. So you could for example save the ID of a node and when you want to load the graph state: 1) Make the node of the previously saved ID the Start node (setting graph.primeNode property), 2) Start the graph, 3) Restore the original Start node immediately so that the graph restarts from it when it resets. Do note however that this will just make the tree start from a specific node. I haven’t really tested this for the purposes of saving/resuming as described in your use case, but it could work. I can make some tests and provide some code if you want to though.

( The ES3 integration by the way, is an integration to call the existing functionality of ES3 from within the NodeCanvas using the tasks included in the integration package. )

To summarize, saving/loading the whole state of a graph is not really supported. Saving/loading Blackboard variables are.

Let me know.

Join us on Discord: