The base Character has an integer value called Fuel which is replicated, because I want everyone to know about it.
.h
UPROPERTY(ReplicatedUsing=OnRep_Fuel)
int Fuel;
.cpp
void ABaseCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ABaseCharacter, Fuel)
}
Fuel can be modified by the following function in the cpp:
void ABaseCharacter::ModifyPlayerFuel(int DeltaFuel)
{
Fuel = Fuel + DeltaFuel;
OnRep_Fuel();
}
void ABaseCharacter::OnRep_Fuel()
{
OnFuelChanged(Fuel);
}
.h
void ModifyPlayerFuel(int DeltaFuel);
UFUNCTION()
void OnRep_Fuel();
UFUNCTION(BlueprintImplementableEvent, Category="Fuel")
void OnFuelChanged(int Fuel);
So far so good. This (seems to) replicate the Fuel value just fine.
But I want to have the value floating above the players’ heads. I’ve hooked this up, and you can see the Blueprints for BP_BaseCharacter:
But the values only change for the player whose screen it is. You can see below (2P w/ dedicated server) that the Fuel value for Client 1 is 1 and for Client 2 is -4, however each only sees their own Fuel value updating in the widget.
Where have I gone wrong??