Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2022.2 beta is now available for testing. To find out what's new, have a look at our 2022.2 feature highlights.
    Dismiss Notice
  3. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
Dismiss Notice
Submit bug reports tagged with #Beta2022Win_Unity when you encounter unknown issues while testing the 2022.2 betas for a chance to win a year of Unity Pro. For more information, have a look at our Beta Sweepstakes Announcement.

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:
    76
    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:
    113
    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:
    76
    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.
     
unityunity