Page 1 of 1

Issue with loading and reading quest state.

Posted: Thu May 12, 2022 11:07 am
by toficor
Hello,
so I am working with Unity Timeline right now, and I'm trying to use

Code: Select all

m_condition.IsTrue(Player.Instance.transform)
with Lua code condition

Code: Select all

CurrentQuestState("followTheFlame") == "unassigned"
to decited if Timeline should be played or not (this condition variable is a serializeField inside my class responsible for starting Timelines). The reason for this is that some Timelines should only be played once on level load depending on quests state.

I think anything is setup properly. I have set bridge between Dialogue System and Quest Machine.
1.PNG
1.PNG (38.64 KiB) Viewed 1053 times
Quest representation in Dialogue Database has thesame id like the one in the Quest Machine Database.

Save system works properly because, when I saved game after getting quest and load after that I have this quest in my QuestJournal component but Lua condition says that my quest state is still "unassigned" and my Timeline is starting.

For saving and loading I'm using your methods from SaveSystem class.

I'm I missing something? Thank you in advance for all help.

Best Regards.

Re: Issue with loading and reading quest state.

Posted: Thu May 12, 2022 11:21 am
by Tony Li
Hi,

Since you're doing this on level load, you may be checking "m_condition.IsTrue(Player.Instance.transform)" before the save system has applied the saved quest journal state to the newly-loaded scene's Quest Journal component.

Instead, check that condition after the save data has been applied. You can use a Dialogue System Trigger set to OnSaveDataApplied or, if you're using a script, change code that looks similar to this:

Code: Select all

void Start()
{
    if (m_condition.IsTrue(Player.Instance.transform))
    {
        // Run timeline.
    }
}
to this:

Code: Select all

void Awake()
{
    PixelCrushers.SaveSystem.saveDataApplied += OnSaveDataApplied;
}
void OnSaveDataApplied()
{
    PixelCrushers.SaveSystem.saveDataApplied -= OnSaveDataApplied;
    if (m_condition.IsTrue(Player.Instance.transform))
    {
        // Run timeline.
    }
}

Re: Issue with loading and reading quest state.

Posted: Tue May 17, 2022 5:29 am
by toficor
That was the fastest response I've ever recieved and it works!!!

Thank you so much.

Re: Issue with loading and reading quest state.

Posted: Tue May 17, 2022 8:10 am
by Tony Li
Happy to help!