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"

Restart level but not reset a variable?


So I have a little script that when the player dies the world resets, and spawns the player at a certain location.

I have a checkpoint system which sets this certain location, but when the level restarts it set back to zero.

How do I reset a level but without setting the variable?

Product Version: Not Selected
more ▼

asked Apr 20 '15 at 03:58 PM in Blueprint Scripting

avatar image

434 97 83 108

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

2 answers: sort voted first

You have to store it somewhere else. Game state object? Game mode object? Savegame file? Depends on your specific needs.

more ▼

answered Apr 20 '15 at 04:56 PM

avatar image

1.3k 48 41 88

avatar image ShrewGlue Apr 21 '15 at 02:09 AM

Alright, can you elaborate on the advantages and disadvantages of each or link me to somewhere that does?

avatar image jwatte Apr 21 '15 at 04:09 AM

The documentation lays out what the different classes do: https://docs.unrealengine.com/latest/INT/Gameplay/Framework/QuickReference/index.html Specifically, look at: https://docs.unrealengine.com/latest/INT/Gameplay/Framework/GameState/index.html And: https://docs.unrealengine.com/latest/INT/Gameplay/Framework/GameMode/index.html

I think what you want for this case is a GameState, although it could be a PlayerState perhaps.

Using LoadMap() to re-load a map after death sounds like it might be slow. If you have a way of re-initializing the character (and any enemies, etc) without re-loading the entire level, that might be faster, and would mean you don't have to track level state separately at all.

avatar image Maceo_P_King Jul 21 '15 at 04:23 PM

I've got a similar question here https://answers.unrealengine.com/questions/261158/reset-level-but-not-reset-variables.html - essentially I followed your advice but I'm still having an issue. I'm sure i'm doing something silly wrong!

avatar image silverfish1000 Jan 17 '17 at 03:40 PM

How would I reset text variables on button pressed. I have open level connected to PLAY button. Do I need to put something before or after. In my button pressed I can get coin widget text 00 node but how do i tell it to reset to 00. Right now is going trough game instance which records how many coins I have collected. The coins get stored inside Game Instance in COIN BANK.

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

Put the variables under Game Instance then on your blueprints, cast to Game Instance to update them. Game Instance is the only one that persists through level changes etc, until the game closes, so at some point if the information is important, save it in a save game using the method documented in the wiki.

more ▼

answered Jul 22 '15 at 05:37 AM

avatar image

986 34 3 41

avatar image MA1 Productions Sep 24 '16 at 03:48 AM

THANKS BRO!!!! i wish i learned about game instances a long time ago

avatar image silverfish1000 Jan 16 '17 at 04:58 PM

How would your reset txt widgets (coins collected) on play button

(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