[SOLVED] Load Quest Game Data from script
Re: [SOLVED] Load Quest Game Data from script
Happy to help.
-
- Posts: 118
- Joined: Thu Dec 19, 2019 7:38 am
Re: [HELP] Load Quest Game Data from script
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.
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
Can you share the line of your code where that error occurs? (Line 55 in your Portal.cs script)
-
- Posts: 118
- Joined: Thu Dec 19, 2019 7:38 am
Re: [HELP] Load Quest Game Data from script
It's just the call to save the game:
Then the SavingWrapper saves the game:
and that then leads to the code for SavingSystem as listed in the above post.
Code: Select all
savingWrapper.Save();
Code: Select all
public void Save()
{
GetComponent<SavingSystem>().Save(defaultSaveFile);
}
Re: [HELP] Load Quest Game Data from script
Hi,
If that's the line, then the NullReferenceException means the variable savingWrapper is null. Is it being assigned properly before this line?
If that's the line, then the NullReferenceException means the variable savingWrapper is null. Is it being assigned properly before this line?
-
- Posts: 118
- Joined: Thu Dec 19, 2019 7:38 am
Re: [HELP] Load Quest Game Data from script
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
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.
-
- Posts: 118
- Joined: Thu Dec 19, 2019 7:38 am
Re: [HELP] Load Quest Game Data from script
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.
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
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.
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.
-
- Posts: 118
- Joined: Thu Dec 19, 2019 7:38 am
Re: [HELP] Load Quest Game Data from script
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.
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.