Page 1 of 1

Start quest from script

Posted: Mon Oct 19, 2020 5:35 am
by nicmar
Hi,
I'm finally back to using Quest machine, and I'm having some troubles starting a quest from a script.
I'm using Unity 2020.1.4 and the latest Quest machine (downloaded 2020-10-19).

When I run this code, thisQuest is null.

Code: Select all

thisQuest = QuestMachine.GetQuestInstance(questReference.id);
thisQuest.SetState(QuestState.Active); // Apparently doesn't work
I have a QuestMachine in the scene. The quest i'm trying to load is in a Quest Database, and the database is in the Quest Machine configuration.

Should I be able do this right from the QuestMachine static, or do I need to get a reference of the QuestMachine in the scene? Did I miss any other vital step?

I'm pretty sure this worked before, but it's probably 6-9 months that I worked with it, and things might have changed between different unity and QM versions.

Thank you in advance! :)

Re: Start quest from script

Posted: Mon Oct 19, 2020 10:21 am
by Tony Li
Hi,

Please see: How To: Start Quest From Script.

Since several people have recently asked about this, I'll wrap up the code in that post into a single method in the next release.

Re: Start quest from script

Posted: Tue Oct 20, 2020 2:27 am
by nicmar
Thanks! :)