Invector shooter saving

Announcements, support questions, and discussion for Quest Machine.
jawgearz
Posts: 11
Joined: Tue Jan 22, 2019 1:22 pm

Invector shooter saving

Post 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.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Invector shooter saving

Post 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).
jawgearz
Posts: 11
Joined: Tue Jan 22, 2019 1:22 pm

Re: Invector shooter saving

Post 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.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Invector shooter saving

Post 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.
jawgearz
Posts: 11
Joined: Tue Jan 22, 2019 1:22 pm

Re: Invector shooter saving

Post 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
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Invector shooter saving

Post by Tony Li »

On the Invector player, try unticking Use Instance.
jawgearz
Posts: 11
Joined: Tue Jan 22, 2019 1:22 pm

Re: Invector shooter saving

Post by jawgearz »

It is unchecked
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Invector shooter saving

Post by Tony Li »

Okay, I'll try to post an example scene by tomorrow.
jawgearz
Posts: 11
Joined: Tue Jan 22, 2019 1:22 pm

Re: Invector shooter saving

Post by jawgearz »

K I really appreciate the help thank you
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Invector shooter saving

Post 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.
Post Reply