How event BeginPlay work?

Hi, i have a simple question…

If i save my game, exit and re-open the game, does the EventBeginplay (of character blueprint for example) launch two times ?

Im trying to make a inventory System with save/load system, and i want to make some things only 1 time (only when the player start a new game)

Thanks, i think this question is maybe stupid but i didn’t found any reply or doc about this…

The BeginPlay is called whenever an actor is spawned. So for example, if you create a Pawn only once at the start of the game, the Pawn’s BeginPlay() is only called once.

Creating a GameInstance and using the Init will definately only be called once per-run through of the game if you are looking for somewhere to do things only once.

You might want to look at the ‘UGameplayStatics::LoadGameFromSlot’ and ‘UGameplayStatics::SaveGameToSlot’ functions for loading and saving to a file.

Thanks for your answer, it help me a lot

Hey there,

Event begin play executes code once after pressing play and resets after you stop the game. So this is a good place to initialize variables like health and such. So Yes if you execute Save game on eventbeginplay, it will save the game every time you press play.

I’m not exactly sure what kind of system you are talking about, but you could probably create a system where it checks if there is a savegame file already inside the savegameobject and base the Save/load for some objects on that or check for certain variables inside it.

Here is a youtube link that explains savegameobjects pretty well, that might be a good place to start.

Hope this was useful!

  • SamuelB

Hey ! My system is : I spawn a blueprint (bp_inventory contain all info about the item im carrying) with an EventBeginPlay in my character blueprint. But don’t want to have multiple instance of this blueprint