Page 1 of 2

reset Dialogue Gamemanager when game restarts

Posted: Thu Aug 04, 2022 2:03 pm
by hrohibil
Hello

In game when player dies after 3 life's, I have a restart button which loads the level again and reset score and life's, but how do I reset the gamemamanger?

It still remembers my first intro talk which is only for first life in the beginning of the game. Where I set a variable to true at the end of talk so I don't have to see the intro again, but in a game restart I want everything back.-

Re: reset Dialogue Gamemanager when game restarts

Posted: Thu Aug 04, 2022 7:12 pm
by Tony Li
Hi,

Call DialogueManager.ResetDatabase() to reset the database variables to their original values. Alternatively, if you're restarting the game you can set up a SaveSystemMethods component and configure an event to call SaveSystemMethods.RestartGame("scene") or SaveSystemMethods.ResetGameState().

Re: reset Dialogue Gamemanager when game restarts

Posted: Fri Aug 05, 2022 3:37 am
by hrohibil
Hey Tony

I created a simple script with this method below:



I attached this script to an GameObject (The gamemanager).
Then on my Gameover "Try Again" onClick button I dragged on this method.

When i play game and get to the point where i click on the try again i get below error
That line 27 is the "ss.ResetGameState();"



Where do i attach my script to? To the gamemanager?


I have these two methods I tried with.
But no luck

Re: reset Dialogue Gamemanager when game restarts

Posted: Fri Aug 05, 2022 8:13 am
by Tony Li
Hi,

Have you assigned 'ss'?

In any case, you don't need that. Just use:

Code: Select all

public class resetGameDialogue()
{
     PixelCrushers.SaveSystem.ResetGameState();
}

Re: reset Dialogue Gamemanager when game restarts

Posted: Fri Aug 05, 2022 8:24 am
by hrohibil
Ok thank you Tony.

I inserted your code instead of the one I had inside my method.

Running the game when clicking the try again/ restart I see in the console that my debug did indeed run, but I don’t get the initial welcome/intro talk?
So I must be missing something.

I have a dialogue system trigger set to start on game start. When this dialogue is completed then I set a variable so I don’t see it again unless I quit game or start all over again..

Re: reset Dialogue Gamemanager when game restarts

Posted: Fri Aug 05, 2022 8:30 am
by Tony Li
Does your Dialogue Manager GameObject have a DialogueSystemSaver?

Re: reset Dialogue Gamemanager when game restarts

Posted: Fri Aug 05, 2022 8:33 am
by hrohibil
Yes it has.

Re: reset Dialogue Gamemanager when game restarts

Posted: Fri Aug 05, 2022 9:34 am
by Tony Li
How are you changing to the first gameplay scene? If you're using SaveSystem.LoadFromSlot() or SaveSystemMethods.LoadFromSlot, it will load your saved game data. If you want to reset the database and load the first gameplay scene, you can use SaveSystem.RestartGame("scene name"). Or, to load the first gameplay scene after resetting with SaveSystem.ResetGameState(), use SaveSystem.LoadScene()/SaveSystemMethods.LoadScene.

Also, make sure you're not using AutoSaveLoad, as this will automatically load your save data.

I recommend ticking the Debug checkboxes on the SaveSystem and PlayerPrefsSavedGameDataStorer components so you can see in the Console when data is being saved or loaded.

Re: reset Dialogue Gamemanager when game restarts

Posted: Fri Aug 05, 2022 11:05 am
by hrohibil
Hi Tony

I tried with this code now. My scene is called "level".

Code: Select all

PixelCrushers.SaveSystem.RestartGame("level");


In my game when all 3 lifes are used, then this GAMEOVER PANEL pops up. When clicking on the Try again button you can see it has 3 OnClick methods attached to it. The bottom one being the one i use to reset the Dialogue Manager..



Here the video show better.

Re: reset Dialogue Gamemanager when game restarts

Posted: Fri Aug 05, 2022 12:51 pm
by Tony Li
Notice that when you restart the game and enter the Wizard's Dialogue System Trigger, the Conditions section says False. I see that the Conditions include Accepted Tags. After you restart, does the player have the tag specified in Accepted Tags? Have you also specified Lua Conditions? If so, what are they?