How can I store the current state of an FSM?

Forums 💬 NodeCanvas ⚙️ Support How can I store the current state of an FSM?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #23077
    yuuna
    Participant

      I’m trying to create FSMs for traps in my scene. The player might enter different levels, and I’m considering unloading previous scenes when the player moves to another one.Obviously, this would also unload the FSMs along with the scene. However, I want to preserve the state of each FSM so that when the player returns to the original scene, the traps can resume from where they left off.

       

      Is this possible?Is there a simple way to achieve this?

      Or is there a better practice?

      #23078
      yuuna
      Participant

        I’m not sure if anyone has asked this question before. It seems that this forum doesn’t have a search function, so I couldn’t check previous posts.If someone has already asked this, I apologize.

        #23079
        redikann
        Participant

          Off the top of my head, I would suggest a Blackboard asset or global scene blackboard. I would create a

          public Enum TrapState      // your custom code needed

          {armed, disarmed, triggered} //suggestions

          Make sure to expose that in the preferred types editor

          Create a dictionary in one of the blackboard suggestions (dictionary (string, trapstate))

          Make the string a unique identifier for each trap and store the current Enum state

          Then look it up whenever logic needs to be refreshed.

          P.S. this doesn’t save between play sessions but would definitely work on any play thru

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