reset Dialogue Gamemanager when game restarts

Announcements, support questions, and discussion for the Dialogue System.
hrohibil
Posts: 368
Joined: Thu Nov 04, 2021 12:50 pm

reset Dialogue Gamemanager when game restarts

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

Re: reset Dialogue Gamemanager when game restarts

Post 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().
hrohibil
Posts: 368
Joined: Thu Nov 04, 2021 12:50 pm

Re: reset Dialogue Gamemanager when game restarts

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

Re: reset Dialogue Gamemanager when game restarts

Post 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();
}
hrohibil
Posts: 368
Joined: Thu Nov 04, 2021 12:50 pm

Re: reset Dialogue Gamemanager when game restarts

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

Re: reset Dialogue Gamemanager when game restarts

Post by Tony Li »

Does your Dialogue Manager GameObject have a DialogueSystemSaver?
hrohibil
Posts: 368
Joined: Thu Nov 04, 2021 12:50 pm

Re: reset Dialogue Gamemanager when game restarts

Post by hrohibil »

Yes it has.
User avatar
Tony Li
Posts: 21975
Joined: Thu Jul 18, 2013 1:27 pm

Re: reset Dialogue Gamemanager when game restarts

Post 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.
hrohibil
Posts: 368
Joined: Thu Nov 04, 2021 12:50 pm

Re: reset Dialogue Gamemanager when game restarts

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

Re: reset Dialogue Gamemanager when game restarts

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