[SOLVED] Load Quest Game Data from script

Announcements, support questions, and discussion for Quest Machine.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: [SOLVED] Load Quest Game Data from script

Post by Tony Li »

Happy to help.
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Re: [HELP] Load Quest Game Data from script

Post by mschoenhals »

Hi Tony,

I've been busy putting together a better inventory system. I took out the saving system for QuestMachine while I was working on the new inventory. However, now if I try and add just add the Save System to Quest Machine I get a NullReferenceException: Object reference not set to an instance of an object.

Here are the particulars:
NullReferenceException: Object reference not set to an instance of an object
RPG.SceneManagement.Portal+<Transition>d__9.MoveNext () (at Assets/Scripts/SceneManagement/Portal.cs:55)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

That line refers to the SavingWrapper where it saves the game. If I remove Save System from Quest Machine, the transition between scenes goes through and no error. Even when commenting out the Quest Machine code mentioned above, if the Save System is on Quest Machine, I still get the error.

The components I have on Quest Machine are currently Quest Machine Configuration, Quest Alert Displayer, and Dont Destroy Game Object.

Thank you for your help in advance.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HELP] Load Quest Game Data from script

Post by Tony Li »

Can you share the line of your code where that error occurs? (Line 55 in your Portal.cs script)
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Re: [HELP] Load Quest Game Data from script

Post by mschoenhals »

It's just the call to save the game:

Code: Select all

            savingWrapper.Save();
Then the SavingWrapper saves the game:

Code: Select all

        public void Save()
        {
            GetComponent<SavingSystem>().Save(defaultSaveFile);
        }
and that then leads to the code for SavingSystem as listed in the above post.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HELP] Load Quest Game Data from script

Post by Tony Li »

Hi,

If that's the line, then the NullReferenceException means the variable savingWrapper is null. Is it being assigned properly before this line?
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Re: [HELP] Load Quest Game Data from script

Post by mschoenhals »

Yes, it works fine if I remove Save System from Quest Machine. SavingWrapper is defined above savingWrapper.Save() here:

Code: Select all

            SavingWrapper savingWrapper = FindObjectOfType<SavingWrapper>();
            player = GameObject.FindWithTag("Player");
            player.GetComponent<PlayerController>().enabled = false;  //disable player control

            yield return fader.FadeOut(fadeOutTime);

            savingWrapper.Save();
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HELP] Load Quest Game Data from script

Post by Tony Li »

Can you send a reproduction project to tony (at) pixelcrushers.com? It sounds like a configuration issue or an issue with the code that's calling SaveSystem. But I'm having a little trouble understanding what's wrong. If I can take a look at a project, I'm sure I can identify it quickly.
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Re: [HELP] Load Quest Game Data from script

Post by mschoenhals »

Here's a link to the zipped file: [removed]
My Unity version is 2018.4.6f1
Right now, if you move the character through the portal to the right, the error will appear in the console. If you remove Save System from Quest Machine, the player continues through to the new scene. Ignore the other warning messages; I didn't include some of the camera components for this example.

Code for saving is found in SavingSystem.cs. Right now, I have the PixelCrushers code commented out.

Note: I have purchased the PixelCrushers Dialogue system and have not yet implemented it. Just mentioning it in case something else will need to be done to the saving system to include this new content.

Thanks.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HELP] Load Quest Game Data from script

Post by Tony Li »

Hi,

Thanks for sending your project. I removed the link from the post so others can't download Quest Machine through it. I'll examine your project today and let you know what the solution is.
mschoenhals
Posts: 118
Joined: Thu Dec 19, 2019 7:38 am

Re: [HELP] Load Quest Game Data from script

Post by mschoenhals »

Hi Tony,
Sorry about sending the link here; I should have known better than to make it open like that. For future reference, how should I send a project?
Thanks for your patience.
Post Reply