Page 2 of 3
Re: [SOLVED] Load Quest Game Data from script
Posted: Sat Mar 07, 2020 9:53 am
by Tony Li
Happy to help.
Re: [HELP] Load Quest Game Data from script
Posted: Thu Apr 30, 2020 11:24 am
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.
Re: [HELP] Load Quest Game Data from script
Posted: Thu Apr 30, 2020 11:44 am
by Tony Li
Can you share the line of your code where that error occurs? (Line 55 in your Portal.cs script)
Re: [HELP] Load Quest Game Data from script
Posted: Thu Apr 30, 2020 12:59 pm
by mschoenhals
It's just the call to save the game:
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.
Re: [HELP] Load Quest Game Data from script
Posted: Thu Apr 30, 2020 1:10 pm
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?
Re: [HELP] Load Quest Game Data from script
Posted: Thu Apr 30, 2020 1:59 pm
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();
Re: [HELP] Load Quest Game Data from script
Posted: Thu Apr 30, 2020 2:06 pm
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.
Re: [HELP] Load Quest Game Data from script
Posted: Fri May 01, 2020 9:56 am
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.
Re: [HELP] Load Quest Game Data from script
Posted: Fri May 01, 2020 1:30 pm
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.
Re: [HELP] Load Quest Game Data from script
Posted: Fri May 01, 2020 4:57 pm
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.