I thought doing like you suggested, but it wouldn’t be ideal.
When a player joins the game, I spawn a character programatically like this:
void AInGame_GameMode::PostLogin(APlayerController* NewPlayer)
{
Super::PostLogin(NewPlayer);
if (AInGame_GameState* InGame_GameState = GetGameState<AInGame_GameState>())
{
InGame_GameState->SpawnPerson(NewPlayer);
Cast<AInGame_PlayerController>(NewPlayer)->SetInputModeGameOnly();
// Here, I want to get the spawned character and load its inventory, hunger, thirsty, money etc. But the "Inventory" property is null.
}
}
I need to access the inventory property just after I spawned the character, so I need do instantiate the UInventory object at the APerson_Character constructor.