Page 1 of 2
Invector shooter saving
Posted: Tue Jan 22, 2019 1:28 pm
by jawgearz
Hi
I using the invector tpc and need some help with the save system. I got everything working except when the player dies he respawns with nothing saved no inventory or quest. When I change scenes everything is good and when I load game everything is good. Any help would be appreciated.
Re: Invector shooter saving
Posted: Tue Jan 22, 2019 3:01 pm
by Tony Li
Hi,
You will need to modify two files: InvectorStatsSaver.cs and vGameController.cs.
In InvectorStatsSaver.cs, add this variable:
Code: Select all
public static bool isResettingScene = false;
At the beginning of the ApplyData() method, add this code:
Code: Select all
public override void ApplyData(string s)
{
if (isResettingScene) { isResettingScene = false; return; } //<--ADD THIS.
This tells InvectorStatSaver to not apply the saved stats when respawning, since the saved stats will be the dead player's stats (i.e., zero health).
Then edit vGameController.cs. In the ResetScene() method (around line 157), change this:
Code: Select all
SceneManager.LoadScene(scene.name);
to:
Code: Select all
PixelCrushers.DialogueSystem.InvectorSupport.InvectorStatsSaver.isResettingScene = true;
PixelCrushers.SaveSystem.LoadScene(scene.name);
This tells vGameController to use the Pixel Crushers Save System to reload the scene. This saves the player's info first, then loads the scene, then applies the info (quests, inventory).
Re: Invector shooter saving
Posted: Tue Jan 22, 2019 6:34 pm
by jawgearz
Hi thanks for reply
In the vGameController I'm getting a compiling error under the InvectorStatsSaver.
Says the name does not exist in current context.
Sorry but I am not very code savvy.
Re: Invector shooter saving
Posted: Tue Jan 22, 2019 6:38 pm
by Tony Li
Sorry, use this:
Code: Select all
PixelCrushers.DialogueSystem.InvectorSupport.InvectorStatsSaver.isResettingScene = true;
PixelCrushers.SaveSystem.LoadScene(scene.name);
I fixed it above, too.
Re: Invector shooter saving
Posted: Tue Jan 22, 2019 6:52 pm
by jawgearz
Thanks again for such fast reply the compiling error is gone but I'm still not getting any saved data on respawns after death
Re: Invector shooter saving
Posted: Tue Jan 22, 2019 6:56 pm
by Tony Li
On the Invector player, try unticking Use Instance.
Re: Invector shooter saving
Posted: Tue Jan 22, 2019 6:58 pm
by jawgearz
It is unchecked
Re: Invector shooter saving
Posted: Tue Jan 22, 2019 7:09 pm
by Tony Li
Okay, I'll try to post an example scene by tomorrow.
Re: Invector shooter saving
Posted: Tue Jan 22, 2019 7:10 pm
by jawgearz
K I really appreciate the help thank you
Re: Invector shooter saving
Posted: Wed Jan 23, 2019 9:17 pm
by Tony Li
Okay, one more line to add. In vGameController.cs's OnCharacterDead() method, add this line:
Code: Select all
PixelCrushers.SaveSystem.RecordSavedGameData(); //<--ADD THIS LINE.
Invoke("ResetScene", respawnTimer);
With that, I don't think you'll need an example scene. If you do, let me know.