Page 1 of 1

Don't Destroy On Load / Possible Instance Issue

Posted: Mon Jun 12, 2023 3:02 pm
by rnally01
Hi,

I'm having an issue where I can pickup and update quests when I get the quest from the scene I start in, but when I load a new scene I'm not able to see the quest update show up in the Quest Alert / Update box on the UI.

I think it might be a multiple instance issue or issue with the Don't Destroy on Load function. My player is an instance and I have the Quest Alert UI as a child of my player. I can see in my hierarchy that the Quest Journal / Alert is using Don't Destroy On Load and it's separating those game objects from the player so I think the issue might have something to do with that.

Have you encountered this before and do you have any suggestions? Should I turn off Don't Destroy On Load for Quest Machine and if so, where is the best place to do that?

Thanks,
Rob

Re: Don't Destroy On Load / Possible Instance Issue

Posted: Mon Jun 12, 2023 4:10 pm
by Tony Li
Hi,

In a typical/suggested setup, there are at least 3 GameObjects:
  • Quest Machine: This is a Don't Destroy On Load GameObject. It coordinates all Quest Machine activity.
  • Quest Journal: Typically on the player GameObject, which exists only in the scene. Holds the player's quests.
  • Quest Giver: On NPCs that offer quests. Typically exists only in the scene.
You can put a Quest Machine GameObject in each scene to make it easy to playtest scenes individually. During play, the first Quest Machine GameObject to exist will survive scene changes and replace Quest Machines in subsequently-loaded scenes.

Each scene will have its own player GameObject with a Quest Journal component. Set the Quest Journal's Save Settings > Key to the same value for the player GameObject in all scenes. Then change scenes using any of the methods in How To: Change Scenes With Save System. The article is in the Dialogue System forum section so the list includes the Dialogue System-specific LoadLevel() sequencer command. Since you're using Quest Machine, just ignore that one item in the list.

Re: Don't Destroy On Load / Possible Instance Issue

Posted: Tue Jun 13, 2023 6:45 pm
by rnally01
I tried using the SaveSystem calls and I'm still seeing the error. I was using SaveSlot(0) before, but I updated it based on the page and link you sent. Here is some more information:

-I'm getting a Message System exception sending error that's attached
-the second image shows the Quest Machine, Quest Alert setup I have on my player. When I start a scene the QuestAlert UI is referenced and connected (screenshot 2), but when I load a new scene the QuestAlert UI is no longer connected (screenshot 3).

Any recommendations?

I'm guessing I should probably just have the QuestMachine Canvas as its own object in the scene rather than on my player, but I just pop up that canvas when the player clicks on a quest button in the pause menu. I'll try to look to see if there is a way to keep the QuestAlert UI referenced.

Re: Don't Destroy On Load / Possible Instance Issue

Posted: Tue Jun 13, 2023 8:31 pm
by Tony Li
Hi,

Since the Quest Machine GameObject survives scene changes but presumably the player doesn't, this breaks the Quest Alert Displayer's link to the quest alert UI. Try moving the Quest Alert Displayer to the player, too.

Re: Don't Destroy On Load / Possible Instance Issue

Posted: Tue Jun 13, 2023 9:42 pm
by rnally01
Hi,

The Quest Alert UI is on the player. It's just parented to the in game HUD UI on the player rather than the Pause Menu UI on the player where Quest Machine is.

I guess I could try parenting it to the Quest Machine game object. It's just helpful to have it where it is for organization and sorting purposes.

This is sort of why I was thinking of it as an instance issue. Would it be a hassle you think to comment out Quest Machine's Don't Destroy On Load code so everything could stay linked and just run through the player? If I was to do that is there one place or checkbox to do that or would I have to comment out a bunch of different places?

Re: Don't Destroy On Load / Possible Instance Issue

Posted: Tue Jun 13, 2023 11:04 pm
by Tony Li
The simplest solution is to move the Quest Alert UI back to the Quest Machine GameObject's hierarchy.

If you don't want to do that, you can keep the Quest Alert UI in the player GameObject's hierarchy, and move the Quest Alert Displayer component from the Quest Machine GameObject to the player.

I recommend keeping the Quest Machine GameObject as Don't Destroy On Load. But if you really can't for some reason, you can remove the Don't Destroy On Load component.

Re: Don't Destroy On Load / Possible Instance Issue

Posted: Thu Jun 15, 2023 3:23 am
by rnally01
The second option worked for me. Thank you for your help!

Re: Don't Destroy On Load / Possible Instance Issue

Posted: Thu Jun 15, 2023 9:08 am
by Tony Li
Glad to help!