Start quest from script

Announcements, support questions, and discussion for Quest Machine.
Post Reply
nicmar
Posts: 133
Joined: Wed Aug 21, 2019 2:39 am

Start quest from script

Post 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! :)
Working on SpaceChef - A wacky open world space western, featuring a chef with nothing to loose, after he loses everything.. ;) Follow our work on @BlueGooGames.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Start quest from script

Post 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.
nicmar
Posts: 133
Joined: Wed Aug 21, 2019 2:39 am

Re: Start quest from script

Post by nicmar »

Thanks! :)
Working on SpaceChef - A wacky open world space western, featuring a chef with nothing to loose, after he loses everything.. ;) Follow our work on @BlueGooGames.
Post Reply