# Uint8 Doesn't Replicate / Trigger OnRep function if Zero

**URL:** <https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195>\
**Category:** Multiplayer & Networking\
**Tags:** Networking, Replication, unreal-engine, bug-report, UE4, CPP, question\
**Created:** [November 20, 2015, 10:06pm UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195 "2015-11-20T22:06:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [November 20, 2015, 10:06pm UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195/1 "2015-11-20T22:06:55Z")

</div>

This seems like it should be a bug, but it may be intentional so posting here just in case. This issue effects a LOT of UE4’s replication, especially serialized rotators. In my case it affects quantized floats.

Essentially, if a Replicated uint8 is changed on the server to be zero from a previous value - it either doesn’t replicate to clients, or it doesn’t trigger the OnRep function on a client.

To get around this, I have had to add a value of ‘1’ to my packed uint8, and remove it again on the client side. This instantly fixes the problem - but of course this limits some of the useful range of the uint8, so this needs to be resolved.

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [December 7, 2015, 7:11pm UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195/2 "2015-12-07T19:11:06Z")

</div>

Hello,

Could you please provide the code that you are working with so that we can attempt to reproduce this issue?

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [January 1, 2016, 12:41pm UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195/3 "2016-01-01T12:41:02Z")

</div>

Hi Sean,

Apologies for the delay. I have attached the code I am working with. The comments should show how to reproduce the issue. It’s possible I believe to modify ShooterGame to see the issue. Unfortunately it’s quite hard to provide an example in this case!

link text

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [January 5, 2016, 6:23pm UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195/4 "2016-01-05T18:23:24Z")

</div>

Hello,

I have investigated this issue further, and have discovered that this is a known issue in our system with OnRep functions not firing on the client (UE-11876).

Have a great day

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [January 22, 2016, 10:09am UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195/5 "2016-01-22T10:09:55Z")

</div>

Thanks Sean,

I don’t suppose you’d be able to provide the details for that case so I can avoid those issues for the meantime could you?

Cheers!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_76ae4db4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_76ae4db4](https://forums.unrealengine.com/u/anonymous_user_76ae4db4)\
**Post date:** [January 25, 2016, 5:41am UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195/6 "2016-01-25T05:41:01Z")

</div>

I would _really_ like to know the answer to this as well. This is a pretty major issue and a C++ hotfix or workaround (even if just some code pasted into an answer from an Epic engineer) would be really helpful.

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [January 25, 2016, 2:32pm UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195/7 "2016-01-25T14:32:09Z")

</div>

This issue is still being investigated by our developers, and there is currently no timeline for when a fix will be released. I will be sure to provide updates regarding this issue as they become available.

---

<div class="post-metadata">

**Author:** ![Ryan\_Gerleve](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ryan\_Gerleve](https://forums.unrealengine.com/u/Ryan_Gerleve)\
**Post date:** [April 29, 2016, 3:19pm UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195/8 "2016-04-29T15:19:37Z")

</div>

Hi TheJamsh,

I took a look at UE-11876, but I think it’s actually unrelated to this issue. Based on the attached code, OverheatData is being modified in the OnRep function. Any modification of replicated variables on a client can cause problems with future replication of that variable, as well as OnReps, since it throws off the server’s assumption about what value the client has.

I would recommend trying to refactor the OnRep function to not modify OverheatData. Granted, I’m only looking at this small snippet, but it looks like it should be possible to use OverheatData to update HeatProgressRatio without writing to OverheatData. Let us know if this fixes the issue!

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [May 16, 2016, 3:52pm UTC](https://forums.unrealengine.com/t/uint8-doesnt-replicate-trigger-onrep-function-if-zero/339195/9 "2016-05-16T15:52:12Z")

</div>

Hey Ryan,

Thanks for looking at the code, I will go through and check it again based on your advice.

Out of interest then, does this mean that the Server uses the OnRep functions itself to determine what it thinks the client currently has? Or does the Client send it’s version of the variables to the server to validate them - and the server then decides whether to send the values out or not?
