Download

I cant replicate base damage from my SRailGun class which class derived from SWeapon. (Networking)

  I create a SRailGun class which class derived from SWeapon. And I cant replicate base damage from my SRailGun class which class derived from SWeapon. I tried to replicate it. Work logic is the weapon is when you hold left mouse button weapon  is charging and every charge you gain extra damage and you release the button, weapon is firing.If you dont release the button, weapon casts automatically.

 In The Server side works fine(BaseDamage,BoostDamage, Cosmetics etc). But when client is shooting his damage doesnt increase.I also used Fire() method from super class.

(Base Damage of the SRailgun is 80.)

I tried almost every replication(BaseDamage, BoostDamage, CanShoot) but still cant solve the problem.

Check replication configured properly.

  1. Replicates SWeapon Actor


// SWeapon::SWeapon constructor
bReplicates = true;


  1. Mark Replicated


UPROPERTY(Replicated)
float BaseDamage;


  1. Override GetLifetimeReplicatedProps


void SWeapon::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    DOREPLIFETIME(SWeapon, BaseDamage);
}


Replication does not guarantee on time(here replicated before fire).

Instead pass damage parameter to Super::Fire function.

@empty2fill I’ve implemented your solutions to code, but the problem still continues.

Hello,
You are replicate only initial value, you need to update it.
uproperty(replicatedusing=functionname)

ufunction()
void functionname(float basedomage)

Hello Sirgomo,

Thank you for your reply but base damage still same amount. I think when SRailGun call the fire function all changes gone and reflects defaultdamage.