Hi,
.cpp:
void ATOCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ATOCharacter, CurrentWeapon);
DOREPLIFETIME(ATOCharacter, KnifeWeaponSlot);
DOREPLIFETIME(ATOCharacter, PistolWeaponSlot);
DOREPLIFETIME(ATOCharacter, SMGWeaponSlot);
DOREPLIFETIME(ATOCharacter, RifleWeaponSlot);
DOREPLIFETIME(ATOCharacter, GranadeWeaponSLot);
}
void ATOCharacter::OnRep_SMG()
{
UE_LOG(LogTemp, Warning, TEXT("SMG changed"));
if (!SMGWeaponSlot) EquipBestWeapon();
}
.h:
UPROPERTY(ReplicatedUsing = OnRep_SMG)
ATOWeapon* SMGWeaponSlot;
UFUNCTION()
void OnRep_SMG();
It works for every case (server equips a new valid weaponactor), but when the weapon gets unequiped (Destroy() + SMGWeaponSlot = nullptr) it does not call the OnRep method on the client.
Is this normal behavior?
Cheers