I’m trying to access a variable in my partyinfo class from my menu class, but how? Here is my code.
menu
APlayerState* PlayerState = Pawn->GetPlayerState();
APartyInfo* PartyInfo;
if (PlayerState) {
if (PartyInfo) {
FString PlayerName = PlayerState->GetPlayerName();
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Blue, PlayerName);
}
else {
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Red, “Party info is nullptr”);
}
}
and party info
class SPELLBOUNDSTUMBLE_API APartyInfo : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor’s properties
APartyInfo();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UFUNCTION()
void OnRep_PartyID();
UFUNCTION()
void OnRep_bIsLeader();
UFUNCTION()
void OnRep_Members();
// Member variables
UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing = OnRep_PartyID)
int32 PartyID;
UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing = OnRep_bIsLeader)
bool bIsLeader;
UPROPERTY(EditAnywhere, BlueprintReadWrite, ReplicatedUsing = OnRep_Members)
TArray<ACPP_Character*> Members;
};
The print “GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Red, “Party info is nullptr”);” always appears when I run this.