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

**URL:** <https://forums.unrealengine.com/t/i-cant-replicate-base-damage-from-my-srailgun-class-which-class-derived-from-sweapon-networking/133426>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [November 13, 2019, 7:30pm UTC](https://forums.unrealengine.com/t/i-cant-replicate-base-damage-from-my-srailgun-class-which-class-derived-from-sweapon-networking/133426 "2019-11-13T19:30:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sharp\_Leaf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sharp\_Leaf](https://forums.unrealengine.com/u/Sharp_Leaf)\
**Post date:** [November 13, 2019, 7:30pm UTC](https://forums.unrealengine.com/t/i-cant-replicate-base-damage-from-my-srailgun-class-which-class-derived-from-sweapon-networking/133426/1 "2019-11-13T19:30:16Z")

</div>

```
  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.

```

 ![RailGunQuestion1.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/2/829454889a3b1008e9560d5b4887dbd4e53752cd.png)

 ![RailGunQuestion2.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/c/1/c1099180a261bf5f96838090f10bb4994cbf6f8c.png)

 ![RailGunQuestion4min.PNG.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/c/0/c042a167c1aae88021d119af597ef8fbff3a72eb.jpeg)

(Base Damage of the SRailgun is 80.)

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

---

<div class="post-metadata">

**Author:** ![empty2fill](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@empty2fill](https://forums.unrealengine.com/u/empty2fill)\
**Post date:** [November 14, 2019, 12:22am UTC](https://forums.unrealengine.com/t/i-cant-replicate-base-damage-from-my-srailgun-class-which-class-derived-from-sweapon-networking/133426/2 "2019-11-14T00:22:53Z")

</div>

Check replication configured properly.

1. Replicates SWeapon Actor

```auto

// SWeapon::SWeapon constructor
bReplicates = true;

```

1. Mark Replicated

```auto

UPROPERTY(Replicated)
float BaseDamage;

```

1. Override GetLifetimeReplicatedProps

```auto

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

    DOREPLIFETIME(SWeapon, BaseDamage);
}

```

1. 

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

Instead pass damage parameter to Super::Fire function.

---

<div class="post-metadata">

**Author:** ![Sharp\_Leaf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sharp\_Leaf](https://forums.unrealengine.com/u/Sharp_Leaf)\
**Post date:** [November 14, 2019, 5:34pm UTC](https://forums.unrealengine.com/t/i-cant-replicate-base-damage-from-my-srailgun-class-which-class-derived-from-sweapon-networking/133426/3 "2019-11-14T17:34:10Z")

</div>

@**[empty2fill](https://forums.unrealengine.com/member/774429-empty2fill) I’ve implemented your solutions to code, but the problem still continues.**

---

<div class="post-metadata">

**Author:** ![Sirgomo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sirgomo](https://forums.unrealengine.com/u/Sirgomo)\
**Post date:** [November 14, 2019, 6:43pm UTC](https://forums.unrealengine.com/t/i-cant-replicate-base-damage-from-my-srailgun-class-which-class-derived-from-sweapon-networking/133426/4 "2019-11-14T18:43:08Z")

</div>

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

ufunction()  
void functionname(float basedomage)

---

<div class="post-metadata">

**Author:** ![Sharp\_Leaf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sharp\_Leaf](https://forums.unrealengine.com/u/Sharp_Leaf)\
**Post date:** [November 14, 2019, 8:57pm UTC](https://forums.unrealengine.com/t/i-cant-replicate-base-damage-from-my-srailgun-class-which-class-derived-from-sweapon-networking/133426/5 "2019-11-14T20:57:53Z")

</div>

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.
