Download

Life system across multiple levels 3D Platformer

Hi All,

I’m still a huge newbie when it comes to Unreal 4, I’m currently working on a 3D platformer in the style of Banjo-Kazooie / Spyro. I was wondering what is the best way to store Life information, like on level 1 I have 2 lifes and I want to keep those 2 lives as i move onto level 2.

Would it be the GameState I put this information in or Game Instance?

Regards
James

For that kind of information, use SaveGame in combination with GameInstance.

GameInstance variables are keeping their values during open Level. So, if you load a SaveGame, load the HP value into GameInstance, and it will persist during all levels.
You can access the Variable with:
Get Game Instance
Cast to: your GameInstance
Get/Set Variable Name

https://answers.unrealengine.com/questions/91531/how-to-use-the-gameinstance-bp-to-send-info-to-oth.html

https://answers.unrealengine.com/questions/189120/whats-the-deferent-between-gamestate-and-game-inst.html

GameInstance is an object that persists through levels (IE when you load another level, it doesn’t get destroyed and you can keep non-pointer variables such as bool and int).

You specify what class of Game Instance you want in your project settings.

You can create your own Game Instance class using the “New Blueprint Asset” tab and opening up the list of objects you have there or directly typing “Game Instance”.