# Can I trust "replicated" variables? And how quickly are they replicated?

**URL:** <https://forums.unrealengine.com/t/can-i-trust-replicated-variables-and-how-quickly-are-they-replicated/1792490>\
**Category:** Blueprint\
**Tags:** variables, Variable, Replication, unreal-engine, UE5, question, Blueprint\
**Created:** [April 7, 2024, 2:42pm UTC](https://forums.unrealengine.com/t/can-i-trust-replicated-variables-and-how-quickly-are-they-replicated/1792490 "2024-04-07T14:42:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fairchild](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fairchild](https://forums.unrealengine.com/u/Fairchild)\
**Post date:** [April 7, 2024, 2:42pm UTC](https://forums.unrealengine.com/t/can-i-trust-replicated-variables-and-how-quickly-are-they-replicated/1792490/1 "2024-04-07T14:42:10Z")

</div>

The game is a grid of tiles that can be changed into walls and towers. When a player clicks on a tile actor, they may need to know whether that tile is a tower, a wall etc.

The grid actors variables are all set on the server. But I’m unsure the best way to go about retrieving that information.

Is there an advantage to using a Server RPC to retrieve the tile actor’s “current state” variable and returning to the player’s controller with that information, versus just having that variable set to “replicate” on the tile actor and NOT using a server RPC?

Using the RPC seems more “secure” because I know the player is getting the right information, and I know the player cannot cheat. But, can they cheat if the logic is all client side but the variable is set to replicate? Or, if I just rely on the variable being set to “replicate”, can I trust the tile’s client instance is going to have the “right” variable state in a timely manner?

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 7, 2024, 2:48pm UTC](https://forums.unrealengine.com/t/can-i-trust-replicated-variables-and-how-quickly-are-they-replicated/1792490/2 "2024-04-07T14:48:40Z")

</div>

> [@Rep Notify vs. RPC vs. Replicated](https://forums.unrealengine.com/t/rep-notify-vs-rpc-vs-replicated/1745633):
>
> I am wondering the difference between A. Using a rep notify to update health, which then runs an update widget event to display current health vs B. Using an RPC to do the same vs. C. Simply replicating the health property, and running a tick function client-side to update the player health every second It seems to me if I want to reduce network traffic option C would be best? Or is using a tick-function high cost on the processor even for something as simple as that. Apologies as I am ver…

This thread sums up the good and bad sides of RPC vs Repnotify vs Replicated.

Also some good info from the documentation

 ![rep](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/e/f/cef908d484694c42e5552cc82b89a0992d1cec6f.png)

> **[Replicate Actor Properties in Unreal Engine](https://dev.epicgames.com/documentation/en-us/unreal-engine/property-replication-in-unreal-engine?application_version=5.0)**
>
> Learn how to replicate actor properties in Unreal Engine; including conditional replication, custom conditions, and object references.

---

<div class="post-metadata">

**Author:** ![Fairchild](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fairchild](https://forums.unrealengine.com/u/Fairchild)\
**Post date:** [April 7, 2024, 3:02pm UTC](https://forums.unrealengine.com/t/can-i-trust-replicated-variables-and-how-quickly-are-they-replicated/1792490/3 "2024-04-07T15:02:39Z")

</div>

Thank you for the quick response, that was helpful. I won’t be changing the variable value on the client. I just need to see what the server says it is, and quickly.

Question though. I found another post with some information regarding timing.

> Replicated variables while are always reliable, aren’t replicated as fast as possible. _They are queued, and replicated in batches at the end of tick._
> 
> RPC on the other hand are replicated to clients the moment they are called (doesn’t mean they will arrive faster than variable, though they usually are). You can send data with RPC (as value parameters), but as per usually it won’t work with UObjects only simple data with defined serialization/deserialization. Most native UE types will work out of box. If you have something special, you have to take care of it, yourself.
> 
> You should use RPC any time you want to get data to clients, as fast as possible and use replicated variables if you just want to synchronize values or state of object.

It sounds like I should be using RPC if I want the client to have the updated information asap. For instance, the player can “click-drag” multiple tiles to create a wall which I could see issues arising if the logic is not getting a guaranteed accurate current variable.

Thread here:

> [@RPCs versus Replication and OnRep-events](https://forums.unrealengine.com/t/rpcs-versus-replication-and-onrep-events/87077):
>
> I’d like to hear some opinions about RPCs and OnRep. In my project I am shifting more and more towards using OnReps instead of RPCs. It just seems much more reliable. And often RPCs can potentially desync the game between machines, especially when you’re thinking about re-connecting to a game or generally joining a game in progress, where all previous RPCs are “missing”. Another problem with RPCs is that necessary replicated data usually isn’t available on the client in time, when you change it …

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 7, 2024, 3:06pm UTC](https://forums.unrealengine.com/t/can-i-trust-replicated-variables-and-how-quickly-are-they-replicated/1792490/4 "2024-04-07T15:06:12Z")

</div>

Though with RPC’s make sure to set them as reliable if you want them a 100% delivered.

The information transfer will always be limited by the network bandwidth. If you eat if up for instance by mistakenly RPCing on tick you can exhaust this resource.

Non reliable RPC’s would be dropped in this case. Not sure about reliable ones, if they are queued for the next packed or not. Haven’t tested it myself but the name does suggest they should arrive if perhaps later.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [April 7, 2024, 3:39pm UTC](https://forums.unrealengine.com/t/can-i-trust-replicated-variables-and-how-quickly-are-they-replicated/1792490/5 "2024-04-07T15:39:18Z")

</div>

think of everything the client does as a request, you can click and drag as many tiles as you want and ask the server can create walls here?

this can be done client side so it feels smooth

the server can then verify it and complete the action.

there will be a delay/lag but assuming no one is cheating or tried to access the same tile at the same time it will usually always work, this is where prediction come in if you want to go down that path.

a server RPC wouldnt help as it’d suffer the same delay/lag anyway so best just request and hope

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [April 8, 2024, 6:00am UTC](https://forums.unrealengine.com/t/can-i-trust-replicated-variables-and-how-quickly-are-they-replicated/1792490/6 "2024-04-08T06:00:44Z")

</div>

> The game is a grid of tiles that can be changed into walls and towers. When a player clicks on a tile actor, they may need to know whether that tile is a tower, a wall etc.

If clients only need to know what something is, then define it in the actor itself.

Create an enum of all the different types of tiles (wall, tower, etc). In each tile actor class add a variable for TileType ( your enum). Set the variable for the class.

When the server spawns it that information will be part of the actor itself and not need replication. You can then easily use a common blueprint interface to locally request the information without having to cast or rpc the server.

The player/controller and the tile actors need to implement the interface.  
Then it’s only a matter of creating “PlayerRequest” and “ActorResponse” functions to communicate locally.
