Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Complete game restart via blueprints?

Is there a way to completely restart a game, equivalent to exiting the game and then restarting, via blueprints?

Not just restarting at the default level, but ending the game instance and starting a new one. Specifically, I have some code in my custom game instance constructor that needs to run.

Thanks, Pagan

Product Version: Not Selected
more ▼

asked Jan 30 '15 at 05:27 PM in Blueprint Scripting

avatar image

135 17 13 23

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey pagancyc-

As long as the game is running it will still be considered the same instance. If you have code that needs to run more than once it would be best to move it somewhere other than the constructor. Then you can have it called by the constructor as well as call it wherever else you need to.


Doug Wilson

more ▼

answered Jan 30 '15 at 07:22 PM

avatar image pagancyc Jan 30 '15 at 08:15 PM

Hi Doug, thanks for the quick reply.

Is there somewhere in particular you would recommend for the scenario detailed below? Or just create a function within the custom gameinstance and call it as needed?

Basically what I am doing is randomizing the map based on a seed that is saved using USaveGame. On startup, if the savegame exists, the seed is loaded and some values randomized. Otherwise, the seed is created, saved and then randomization is done. Those randomized values are then used in the PostInitializeComponents functions of some custom classes to change how (and whether) they appear.

I would like to have a menu option to restart (preferably via blueprints), which would delete the existing savegame, generate a new seed and a new map, and then start the player off fresh.

Thanks very much, Pagan

avatar image Doug E ♦♦ STAFF Jan 30 '15 at 08:43 PM

The game instance is created as soon as the game begins to run. Assuming there is some sort of start menu, the game instance has already been created by the time you would get to it and will continue until the game is shut down (or the reset button is pressed on a console).

For what you're trying to do it would be best to generate the seed when loading into the level. If the game is shut down and reopened the seed is still saved (via the method you described). Otherwise if Reset is chosen from the option menu you delete the seed at that point and return to the start menu (at which point a new seed will generate when you load into the level again).

In either case your best bet would be to create a function that is called when you begin "playing" the game rather than doing so in the game instance.

avatar image pagancyc Feb 02 '15 at 06:30 PM

Got it working great now, thanks again for your help.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question