Variables set in blueprint class have no effect in client mode cpp class

I’m setting the variables in the class header, but they aren’t getting changed.

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TSubclassOf<class UHudWidgetPrimary> PlayerHUDClass;

	UPROPERTY()
	class UHudWidgetPrimary* PlayerHUD;

In the .cpp file, I use this to get them

	if (IsLocallyControlled() && PlayerHUDClass)
	{
		AMainPlayerCharacter::PlayerHUD = CreateWidget<UHudWidgetPrimary>(GetGameInstance(), AMainPlayerCharacter::PlayerHUDClass);
		AMainPlayerCharacter::PlayerHUD->AddToPlayerScreen();
	}
	else
	{
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("HUDclass is equal to %x"), PlayerHUDClass));
	}

I have set the blueprint class to be the class that the game uses in the Project Settings, and it works in the standalone mode.

Other variables are set by the blueprint, and they all return as null when I try and access them.

Found the issue! My UPROPERTY variables were defined with the public: access specifier above, when they needed to be private- everything works perfectly now!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.