How to get player HUD object from SaveGame

I believe this should work, but not sure, and pretty confident there is a better way of doing this.

How to I get a HUD object of a certain player controller from a USaveGame derived class?

Here’s my current workaround:

void UDHSettingsSave::ApplyCrosshairType()
{
	AActor* ActorDummy = GetWorld()->SpawnActor(AActor::StaticClass());
	int32 ControllerId = ActorDummy->GetGameInstance()->LocalPlayers[0]->GetControllerId();
	ActorDummy->Destroy();

	ADHHUD* DHHUD = Cast<ADHHUD>(UGameplayStatics::GetPlayerController(this, ControllerId)->GetHUD());
	if (DHHUD) DHHUD->CrosshairWidget->SetCrosshairType(CrosshairType);
}

You could just do GetWorld()->GetGameInstance() ?

Yeah, but how do you get the HUD object from game instance?

I’m not entirely sure you should be using the HUD to store state information. I’m sure what you’re doing should be okay, though? Why do you need to change a widget in a save game?

The save game contains local user settings, and crosshair widget type needs to be set from the apply method

I didn’t say you shouldn’t save state info, I said you shouldn’t put it in your hud class. The type of crosshair used should be on your player state, really. That’s what it’s there for. Then, when you load your save game, your player state inits the hud. Or the hud, on load, checks the player state class. That way you don’t even need to save the hud, you just create a new one when you load your save game.