Help please. How do I transfer a character from one level to another? At one level, the user selects a character, and then they are joined with the server. Character components are added in runtime. How to make so that they are preserved?
Use a Game Instance to “save” the details about what character the player has selected, and when you load the next map, you read that data and spawn a new character from that.
The Game Instance is created once when you launch the game, and stays even if you switch levels or connect to a server.
Do I need to duplecate components in GameInstacne? Or just store pointer? When the level is closed, all the actors and their components are destroyed? Whether pointer on the component will remain valid. It is very inconvenient to recreate component SetMesh (), then the parameters and so on.
You won’t be able to create any components because there won’t be a valid world.
All you will be able to do is store ‘Data’, then when the new level opens you have to create a new character and fill it’s data back up again from the saved data.
Imagine you are in a class based shooter, and the player has a colo and a pawn class. In that case, you store the player selection into the game instance, for example:
FColor PlayerColor; TSubclassOf<PlayerBaseClass> PlayerClass
Then, in your gamemode, when you need to create the pawn for a new player, you read the game instance, and use its PlayerClass and its PlayerColor to spawn and set the data of that particular new pawn.