Forum rules - please read before posting.

Where to place Engine: End Game --> Restart Game ?

I am presuming I need this when clicking on New Game in the main menu of my game to reset variables? I can't quite work out where to put it though.

My whole game is in one scene, including the main menu, so if I trigger this node after clicking New Game will this send me back to the main menu start again?

If I put it in OnStart ActionList, won't it just keep running OnStart in a loop?

Advice very much appreciated.

Thanks.

Comments

  • edited September 2019

    When you say "main menu", do you mean the menu that only appears at the start of the game - or the one that can be accessed at any time (i.e. like the default AC "Pause" menu)?

    Whenever you call this, it'll reset variables, inventory, save data etc, and then load the scene specified in the scene (reloading the scene if it's set to the one currently open). Triggering it upon clicking a "New Game" Menu button is typically the way to use it.

    If I put it in OnStart ActionList, won't it just keep running OnStart in a loop?

    Yes, it would - since the Action will force a reload of the scene.

  • It's the Main Menu at the start of the game, separate from the Pause Menu.

    If I trigger it on New Game, won't it just Load the Main Menu again, since that is what loads at the start of the scene? All my game is one scene.

    Is it possible to reset all that data without loading a scene?

  • If it's at the start of the game, I don't understand why you're looking to reset the data.

    You can, however, clear variable data through script:

    AC.KickStarter.runtimeVariables.OnStart ();
    
  • Thanks for that.

    So I'm understanding from what you're saying that data is reset anyway when quiting out the game and running it again?

    There is also the case of when someone completes the game it will return to the main menu, if they play again I want the data reset. Also if you quit your game and go to the main menu and start a new game I again want the data reset. Am I thinking/understanding correctly?

  • edited September 2019

    Quitting the game's application and re-opening will cause all non-options data to be reset, yes.

    To reset the data upon completing the game, best to use the "Reset" Action at the end of the game / upon quitting, to bring them back to the main menu scene - as opposed to resetting the game when clicking "New Game".

    Again, though, this can all be done through script. Actions generally work by just calling AC's "proper" core functions to actually do the work. The full block of code, used by the Action, to reset everything (without the scene change) is as follows:

    KickStarter.ResetPlayer (KickStarter.settingsManager.GetDefaultPlayer (), KickStarter.settingsManager.GetDefaultPlayerID (), false, Quaternion.identity);
    KickStarter.saveSystem.ClearAllData ();
    KickStarter.levelStorage.ClearAllLevelData ();
    KickStarter.runtimeInventory.OnStart ();
    KickStarter.runtimeDocuments.OnStart ();
    KickStarter.runtimeVariables.OnStart ();
    KickStarter.playerMenus.RebuildMenus ();
    KickStarter.eventManager.Call_OnRestartGame ();
    KickStarter.stateHandler.CanGlobalOnStart ();
    

    If placed in a custom script, you can pick and choose which functions you want to call.

  • Using the Reset Scene action. Hopefully this will do it.

    In case I want to use it in the future I'm a bit unsure of why you've pasted the code above in 3 different html containers. Not sure which to use or how to arrange it. Does it all all just go in a script together in the order you pasted it here?

    Thanks very much for the information.

  • Just a formatting issue - have addressed.

  • Ah cool, thanks.

  • So I've tested using the Reset Scene function and its not reseting all variables.

    I have a variable which basically states where the camera should be and what area of the game is running - linking to appropriate ActionLists to setup for whichever area is listed there. I have this set with an initial value of "Main Menu". I start playing the game and as I move through this updates as expected and as it always has done. With it currently listing "Hallway", I click on a hotspot which triggers the Reset Scene Action and it attemps to reset but does not change this variable back to its initial value, so I start in the Hallway instead of the Main Menu. I assume it probably changes none of my other variables to initial values either.

    What am I doing wrong here?

  • So continuing my investigations, using Restart Game does in fact work and reset those variables. What is the difference between Reset and Restart apart from being able to choose a scene with Restart?

  • Resetting a scene will not reset the variables - those are game-wide and should not be affected by the resetting of the scene.

  • Noted, thanks.

  • I have a problem like this, I have 3 scenes. The first is the main title of the game, the other is the stage and the third is the game over -continue screen.

    What happens is that the timer, score etc end up being saved, when the player dies and goes to the game over-continue screen, then when it restarts it does not restart the score, timer etc.

    KickStarter.ResetPlayer (KickStarter.settingsManager.GetDefaultPlayer (), KickStarter.settingsManager.GetDefaultPlayerID (), false, Quaternion.identity);
    KickStarter.saveSystem.ClearAllData ();
    KickStarter.levelStorage.ClearAllLevelData ();
    KickStarter.runtimeInventory.OnStart ();
    KickStarter.runtimeDocuments.OnStart ();
    KickStarter.runtimeVariables.OnStart ();
    KickStarter.playerMenus.RebuildMenus ();
    KickStarter.eventManager.Call_OnRestartGame ();
    KickStarter.stateHandler.CanGlobalOnStart ();

    I saw this code above, I put it in a new script, it gave a lot of errors, I don't know where and how to paste this code.

  • Put the code aside - it's old and for a very specific sitatuion.

    The Engine: End game Action can be used to restart the game. If that's not doing what you want, how does it differ?

  • I used Action Engine: End game , but this causes the game to end by closing the game making it impossible to go to the menu to continue a new game.

  • I used Action Engine: End game , but this causes the game to end by closing the game making it impossible to go to the menu to continue a new game.

    I found out how to solve it, it was a function that I hadn't seen yet in the Action Engine itself: End game --->comand: restart game scene to restart to --->

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.