Quests not loading (they are saving though)

Announcements, support questions, and discussion for Quest Machine.
joshualoveridge
Posts: 19
Joined: Tue Jan 01, 2019 12:53 am

Quests not loading (they are saving though)

Post by joshualoveridge »

Hey Tony,

for some reason the load system wont work for me ( im using the Savesystem component, no auto save)

This is my save/load script

Code: Select all

using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
using PixelCrushers;

namespace MoreMountains.InventoryEngine
{
	/// <summary>
	/// An example of a game manager, the only significant part being how we trigger in a single place the load of all inventories, in the Start method.
	/// </summary>
	public class InventoryDemoGameManager : Singleton<InventoryDemoGameManager> 
	{
		public InventoryDemoCharacter Player { get; protected set; }
		bool bad;

			public SaveSystem saveobj;


		protected override void Awake () 
		{
			base.Awake ();
			if(bad){
			Player = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryDemoCharacter>()	;
			}
		}

		void OnApplicationQuit(){
			
			MMGameEvent.Trigger("Save");
			saveobj.SaveGameToSlot(0);

		}

		/// <summary>
		/// On start, we trigger our load event, which will be caught by inventories so they try to load saved content
		/// </summary>
		protected virtual void Start()
		{
            MMGameEvent.Trigger("Load");
		StartCoroutine(wait());

			
		}


		IEnumerator wait(){
			yield return new WaitForSeconds(2f);
		saveobj.LoadGameFromSlot(0);


		}
	}
}
and i get this error on load of the game

Code: Select all

Quest Machine: Main Player Can't find quest HideandSeek. Is it registered with Quest Machine?
UnityEngine.Debug:LogError(Object, Object)
PixelCrushers.QuestMachine.QuestListContainer:ApplyData(String) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:379)
PixelCrushers.QuestMachine.QuestJournal:ApplyData(String) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestJournal.cs:182)
PixelCrushers.SaveSystem:ApplySavedGameData(SavedGameData) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:597)
PixelCrushers.SaveSystem:LoadGame(SavedGameData) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:663)
PixelCrushers.SaveSystem:LoadFromSlotNow(Int32) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:520)
PixelCrushers.SaveSystem:LoadFromSlot(Int32) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:497)
PixelCrushers.SaveSystem:LoadGameFromSlot(Int32) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:418)
MoreMountains.InventoryEngine.<wait>d__9:MoveNext() (at Assets/InventoryEngine/Demos/PixelRogue/Scripts/InventoryDemoGameManager.cs:48)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
How do i go about making sure the quest is registered ?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests not loading (they are saving though)

Post by Tony Li »

Hi,

Did you add the HideAndSeek quest to the quest database that's assigned to the Quest Machine GameObject?

Note: In the current version, the 'Add All Quests In Scene' button has a bug. It doesn't mark the database changes to be saved to disk, so they're not saved when you quit and restart Unity. It's fixed in the version pending release on the Asset Store. In the meantime, please add quests manually to the quest database.

Also make sure the Quest Machine GameObject is present at the time that your manager script calls saveobj.LoadGameFromSlot(0).
joshualoveridge
Posts: 19
Joined: Tue Jan 01, 2019 12:53 am

Re: Quests not loading (they are saving though)

Post by joshualoveridge »

Thank you that fixed it,

I have only 1 more issue, I have an active saver script on my gameobject that holds the items for the quest,
The save and load on this dont seem to be working, although im not sure if im doing it right,

I have the active saver on the object I want to save (its state and its childrens state), do i need to place an active saver on all the children or am i doing it right ?

If i am doing it right how would i debug why its not saving ?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests not loading (they are saving though)

Post by Tony Li »

Hi,

Active Saver needs to be on a GameObject that stays active, which can be an empty GameObject. Assign the object you want to save to its Target field.
joshualoveridge
Posts: 19
Joined: Tue Jan 01, 2019 12:53 am

Re: Quests not loading (they are saving though)

Post by joshualoveridge »

Yes that is the setup i currently have with it but it doesnt seem to be loading/saving,

what would the debug steps be?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests not loading (they are saving though)

Post by Tony Li »

Make sure the Active Saver is not on the GameObject that you want to save. Also make sure it has a unique key.

Tick the Debug checkboxes on the Save System component and the PlayerPrefs Saved Game Data Storer or Disk Saved Game Data Storer. When you load, it will log a JSON representation of the saved game data. Look for the Active Saver's key and its corresponding true/false value.

If the value looks correct, something else may be forcing the target into whatever state it's in after the Active Saver sets its state.
joshualoveridge
Posts: 19
Joined: Tue Jan 01, 2019 12:53 am

Re: Quests not loading (they are saving though)

Post by joshualoveridge »

Thanks ive found an interesting test case

The gameobject itself is actually saving but the state of the child game objects of the saved gameobjects is not being saved,

What is the correct way to go about ensuring the child objects states are being saved as well as the parent?
should i be adding an active saver for each?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests not loading (they are saving though)

Post by Tony Li »

Yes, add an Active Saver to each. It only saves the state of the Target, not its children.
joshualoveridge
Posts: 19
Joined: Tue Jan 01, 2019 12:53 am

Re: Quests not loading (they are saving though)

Post by joshualoveridge »

is there a more elegant way to put them all into an array and save that or something ? ( I will have like 300 items that need their status saved if they need to be individual)
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests not loading (they are saving though)

Post by Tony Li »

Yes. The next version has a Multi Active Saver component. When I get back to the office in about 45 minutes, I'll send you a package with this component.
Post Reply