How to save and restore the current state of behavior tree?

Forums 💬 NodeCanvas 🗨️ General Discussion How to save and restore the current state of behavior tree?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13350
    xtro
    Participant

      I’m implementing a save/load system for my real-time game. Since the game is real-time, I need to be able to save and restore the state of behavior tree of my characters.

      How can I do that?

      Please don’t say, it’s impossible 🙁

      #13354
      Gavalakis
      Keymaster

        Hello there,

        The state of a behaviour tree can not be stored entirely as-is. However, the best solution to save/load the state of your characters behaviour tree is to save and load the blackboard variables that the tree is using instead. Then based on these variables and the design of the tree, the flow can be directed towards the branch you need the tree to follow and as such effectively restoring the state of the tree (mostly meaning which leaf node is currently Running).

        The variables of the Blackboard component attached on the gameobject (alongside BehaviourTreeOwner) can be saved and loaded through the Serialize and Deserialize methods it has. Blackboard.Serialize will return a json string (which will of course need to be stored somewhere like a text file or Unitys PlayerPrefs), and the Blackboard.Deserialize method takes a string parameter where you basically pass the previously saved json.

        Please let me know if that works for you.
        Thanks.

        #13353
        xtro
        Participant

          That approach would make my already-complex nested trees much more complex.

          I’m so sorry that behavior tree doesn’t have a general save/load support 🙁

          #13352
          xtro
          Participant

            As a summary, It’s almost impossible to make a real-time strategy game with NodeCanvas. So sad 🙁

            #13351
            elefantopia
            Participant

              If you haven’t yet found an alternative, try out PandaBT pro.

            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.