Page 1 of 1

Quest getting deleted prematurely in QuestGiver Quest list

Posted: Sat Mar 20, 2021 9:36 pm
by jlhacode
QuestMachine version 1.2.14 running on Unity 2020.2.3f1

I’m trying to create a Quest Debugger that can give testers a way to assign quests to themselves. After assigning a quest to myself and restarting the editor play session, I run into a problem where QuestGiver quests get deleted after passing the quest.timesAccepted check in QuestGiver.DeleteUnavailableQuests(). I’m assuming m_timesAccepted is being persisted on the ScriptableObject. Is there any way I can prevent this?

I also noticed a race condition between my Debugger.Start() script and the QuestGiver.Start(). Both Debugger and QuestGiver are components on the same GameObject. QuestGiver.Start() is always hit first in the scene that’s open when the play session is started, otherwise Debugger.Start() is hit first. I have no idea why this is. I'm loading the QuestGiver with Quests from a QuestDatabase reference in Debugger.Start(), so this race condition causes QuestGiver to have all its quests in the scene that’s first loaded (running the DeleteUnavailableQuests() method before the QuestGiver's quest list gets populated.). This happens even after leaving and returning to the scene in the same play session.

Re: Quest getting deleted prematurely in QuestGiver Quest list

Posted: Sat Mar 20, 2021 9:42 pm
by Tony Li
Hi,

Quest Machine shouldn't modify the asset version of the quest, unless maybe something in your debugger is running an operation before QuestGiver.Start() has run.

To resolve the race condition, wait for the end of the frame. Example:

Code: Select all

public class Debugger : MonoBehaviour
{
    IEnumerator Start()
    {
        yield return new WaitForEndOfFrame();
        // (your code here)
    }
}