Respawning/Restart Game Mechanic

Hello,

I am new to UE4, and I am trying to make a simple endless runner game. I have basic mechanics like save game/score, best score, etc.

However, I’m having trouble with the respawn mechanic. When the player hits a wall and dies, I want them to be able to press space bar, and have the game reset to the beginning, but keep their best score in tact. Can someone tell me how to do this? Been stuck for a few days, and I can’t figure out how. This is what I would think should work, but it’s not. Not sure what I’m doing wrong?

Try to save your variables in gamemode or game instance instead of putting your variables in character BP since once the character destroy all the variables will get reset .

Hello I’m new to UE4 too and creating a similar thing. Today I watched few tutorials on how to save stuff to save my coin number inside my game. Not sure if this will work for you but I’m sure you can learn something from it. Here are the two tutorials I followed and combined in a way to get them to work for me.

Save/Load Menu Settings - Unreal Engine 4 Tutorial - YouTube by CodeViper

Save/Load Game System Intro - #66 Unreal Engine 4 Beginner Tutorial Series - YouTube by Virtus Learning Hub / Creative Tutorials

So far I don’t have any reset button it will keep loading the last coin count on begin play and when I hit my save key (F3) it will save my current coin count. However I believe it could be easily set up to update on item pickup or every now and then via simple function.

Here is my set up (it’s a mix of the two tutorials so don’t worry about my naming concept, as I said I’m new :D)

1. Start by creating a new blueprint and chooses Save Game as type. Name it whatever you want in my case it’s SaveGameTutorial.
1.png

2. Open newly created blueprint and add new variables. This will be the things you want to save, for me it’s SilverCoins and GoldCoins. Compile and save then close this blueprint. You won’t need it anymore but whatever name you assisned keep it in mind, you’ll need it later.

2.png

**3. **Go inside your character blueprint and add new variable as show on the screen. You can skip this point and create this below when you create Save Game Object that how I created that variable.

3.png

4. Now create 3 functions, SaveGame, LoadGame and UpdateWidget

  • Inside your newly created SaveGame function select SaveGame node and add two inputs. Here you create your save game object, assign the name of the blueprint we first created to store all the information, for me it’s SaveGameTutorial. Rest should be clear if not you can learn from the videos or ask a question.

  • In your LoadGame function select your return node and add two outputs just like in SaveGame function. This will check if your save exist (make sure it matches the slot name of your save game) if it does it will load everything and if not it will set every value to 0.

  • UpdateWidget is simple just add two inputs: SilverCoins and GoldCoins, then grab your variables (SilverCoins and GoldCoins) from the left hand side and set them to whatever comes out the update widget.

5. Change to EventGraph inside your character blueprint and Input Event for F3 key, get your save game function and plug it into pressed event, plug variables that need to be saved.

6. Add on event begin play and plug your load function followed by your update function.

So now when I play my game and hit F3 key it will save my Silver and Gold coin count and load these values next time I respawn/start the game. I know this is not a perfect solution and it might not work for you but it’s a start and I strongly suggest you watch the tutorials above. Good luck with your projects! Regards!