When the level changes, everything is initialized. So I try to update the player’s information when a new level is loaded.
I heard Game Instance can do that. So I made Getter, Setter function of player information in game instance class.
But problem is I didn’t get where and how to use those functions. I tried to use those at Level Blueprint BeginPlay function but it didn’t work.
Hello! I think there are several options, but I use singleton UGameInstance and wrap StartOpenLevel and EndOpenLevel functions in it to do the trick you are describing (player data, save|load, post loading checks and etc). So, in LevelBlueprint Begin play I just get this singletone and call EndOpenLevel. I can say it is comfortable enough in many cases
I wouldn’t use the LevelBlueprint for this sort of thing. Use the player objects themselves. Since we are talking about player information, I will assume this data is handled by a player controller. Before loading the next level, submit the data from the player controller to the Game Instance using the Setter function you have created. When the new level loads, on begin play inside the player controller, access the game instance and retrieve your data using the Getter function you setup.
Also, make sure your custom game instance is set in the project map and modes, otherwise, the default Game Instance will be used and you will not be able to access your custom functions.
On a side note, technically this will work as the GameInstance will remain persistent. However, the GameInstance is designed to control the rules of the application, so things such as player information is pretty irrelevant to the class. For good practice, I would suggest you use a save object and write player information to that object before you load the level and access the save object once the new player controller has initialised.
I have previously answered a few questions on this topic: