Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Save and restore state of AI planner?

Discussion in 'AI & Navigation Previews' started by Noxalus, Jul 14, 2020.

  1. Noxalus

    Noxalus

    Joined:
    Jan 9, 2018
    Posts:
    80
    Hello everyone!

    I'm starting to use AI planner for my agents and I would like to keep the current action of every agents when I save the game to restore it when the save is loaded.

    Do you know if I can do that with the version 0.2.3? How could you do if it's possible?
     
  2. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    119
    Technically, you can grab the current action from the DecisionController then save/serialize it however you'd like. That said, interrupting and saving the current execution of the action to be resumed later will be more difficult. Also, we don't currently ship with any utilities for serializing the complete plan to be reloaded later. The easiest method of resuming will be to finish the action, query the world for a new state, then replan.
     
  3. Noxalus

    Noxalus

    Joined:
    Jan 9, 2018
    Posts:
    80
    Thank you for the answer @TrevorUnity !

    The main problem for me is that in a coroutine specified in an action's callback, it's possible to alter object data, and if we save the game state whereas this method has only executed half of its operations, it will cause several issues...

    So yeah, like you said, it would be much more easier if the current action is finished before to save the game state, even if with +100 agents it could be a little be complex to make sure no one is currently executing an action :/

    Anyway, thank you again for your feedback, I will try to find a solution for that.