ActorGun is spawned dynamicly.
By SetOwningPawn(..) the MyPawn is set as owner.
On every shot I call method (on Server), which changes property of ActorGun, named LastShotInfo.
This prop. is declared such way:
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_LastShotInfo, Category = "Shot")
FLastShotInfo LastShotInfo;
FLastShotInfo here is the USTRUCT type name.
LastShotInfo inside AActorGun::GetLifetimeReplicatedProps(..) is added without any conditions:
DOREPLIFETIME(AActorGun, LastShotInfo);
So, I expect, method OnRep_LastShotInfo(..) will be called on every relevant (e.g. located <= some distance) client every time the LastShotInfo property is changed.
This method I’ve defined such way:
void AActorGun::OnRep_LastShotInfo()
{
PlayShot(); //! plays cosmetic
if (Role == ROLE_AutonomousProxy)
{
OnShot.Broadcast(); //! signal to current client UI to redraw some effects.
}
}
I want the OnShot.Broadcast() to be called only on owning client to redraw UI only for player, who have did this shot
BUT! this broadcast is never called =(
Every time, I fall inside OnRep_LastShotInfo(..), the Role is == ROLE_SimulatedProxy.
Why is it so?
How can I separate unique logic for owner client only inside the OnRep_LastShotInfo() method?