Quest getting deleted prematurely in QuestGiver Quest list

Announcements, support questions, and discussion for Quest Machine.
Post Reply
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Quest getting deleted prematurely in QuestGiver Quest list

Post 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.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest getting deleted prematurely in QuestGiver Quest list

Post 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)
    }
}
Post Reply