Hey guys, i have a problem with coding a RepNotify variable from c++ and that is it’s not being replicated at all. I’m trying to follow somehow similar steps to the Blueprints tutorial that was put on some days ago.
in my character’s header file i have this variable that i want to replicate:
UPROPERTY(ReplicatedUsing = UpdateCharacterStatus)
float HealthPoints;
void Update_Character_Status();
//public function that will call another function to update the text being rendered above the character's head. That other function is (Update_Character_Status).
UFUNCTION()
void UpdateCharacterStatus();
in my character’s cpp file
// implementation of the two functions mentioned above.
void Athird_PersonTrialCharacter::Update_Character_Status()
{
CharacterText->Text = FString("HP: ") + FString::FromInt(HealthPoints) + FString(" BombCount: ") + FString::SanitizeFloat(BombCount);
}
void Athird_PersonTrialCharacter::UpdateCharacterStatus()
{
Update_Character_Status();
}
//inside the tick function i have the health variable being reduced by 1 and then being reinitialized.
(HealthPoints <= 0) ? HealthPoints = 100.0f : HealthPoints -= 1.0f;
i also have the variable (HealthPoints) in :
void Athird_PersonTrialCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
// Replicate to everyone
DOREPLIFETIME(Athird_PersonTrialCharacter, HealthPoints);
}
Am i missing something or doing something wrong? would be very thankful if someone could help with this!