# Can RepNotify be faster? or safer?

**URL:** <https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681>\
**Category:** Multiplayer & Networking\
**Tags:** unreal-engine, question, CPP\
**Created:** [December 1, 2024, 2:51am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681 "2024-12-01T02:51:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 1, 2024, 2:51am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/1 "2024-12-01T02:51:34Z")

</div>

I did a test for the RepNotify method and found that it cannot handle high frequency requests.  
The test is a bit extreme but very simple.

.H

```auto
UPROPERTY(ReplicatedUsing = NotifyTheClient)
bool Value = false;

UFUCTION()
void NotifyTheClient()

void ServerSetValue();

void Test();

```

.CPP

```auto
void AMyActor::ServerSetValue() //In Server Scope
{
       Value = !Value;
}

void AMyActor::Test() //In Server Scope
{
       for (int i=0;i<100;i++) ServerSetValue();
}

void AMyActor::NotifyTheClient() //In Client Scope
{
         UE_LOG(LogTemp, Log, TEXT("%i"), Value);
}

```

In this case the client only receives 4 or 5 notifications (it has lost approximately 95% of the requests).

Ok, I know this is an extreme example… I know that the CPU is thousands of times faster than the Socket connection.

Can RepNotify be faster?  
I think that if it is able to process 100 requests in one second, I can rest in peace.  
I think it’s more than I need. But I think it’s better to have too much than not enough.

If it can’t be done quickly,… Can data be sent to the client in a queue?  
I would feel better if I could make sure that the data is not lost (even if it arrives late).  
Better late than never.

Does anyone know how to do this?  
Thank you so much!!

---

<div class="post-metadata">

**Author:** ![silnarm](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/silnarm/32/955303_2.png) [@silnarm](https://forums.unrealengine.com/u/silnarm)\
**Post date:** [December 1, 2024, 3:10am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/2 "2024-12-01T03:10:55Z")

</div>

Does this test really give you 4 or 5 notifications?

It should give you 0.

Flipping a boolean 100 times (an even number) will leave it in same state it started in, and as this is all happening in one frame, there should be nothing to replicate (nothing actually changed, frame to frame).

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 1, 2024, 3:21am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/3 "2024-12-01T03:21:33Z")

</div>

I’ve actually simplified the example a lot… my real code is much more complex. It probably lasts four or five frames.

Thanks for the explanation. I didn’t know it worked that way.  
In any case, I would like not to lose information even if it happens in less than one frame.

Is there any way to force replication?

---

<div class="post-metadata">

**Author:** ![silnarm](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/silnarm/32/955303_2.png) [@silnarm](https://forums.unrealengine.com/u/silnarm)\
**Post date:** [December 1, 2024, 3:34am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/4 "2024-12-01T03:34:54Z")

</div>

There is `AActor::ForceNetUpdate()`, Looking around I saw some conflicting anecdotal evidence on whether it updates immediately or queues, a _quick_ (not very thorough) look at the code suggests it queues, so this may not be sufficient.

If you absolutely must know about every change, reliable RPC may be the only way.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 1, 2024, 3:40am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/5 "2024-12-01T03:40:45Z")

</div>

I will try it.  
Thank you very much for your help

---

<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:** [December 1, 2024, 4:19am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/6 "2024-12-01T04:19:06Z")

</div>

you can also just increase the NetUpdateFrequency on the Actor, some actors are quite slow by default like GameState

but Silnarm is correct, you’re not losing anything it just updates the latest value.

Can it be faster, maybe lag will always be lag but it is safe

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 1, 2024, 5:34am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/7 "2024-12-01T05:34:51Z")

</div>

Yes, I also tried increasing the frequency, but it didn’t solve the problem. I increased it to 10000 and only got a few more executions on the client side.

I think I’ll have to change the design… I have multiple actors changing the value of this replicated variable. I thought it would be replicated instantly but since it does it once per frame it doesn’t work as expected.

If two actors change the variable in a single frame, only one of them receives the notification.

I definitely need another design.

Thank you so much!! @Auran131

---

<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:** [December 2, 2024, 10:40pm UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/8 "2024-12-02T22:40:55Z")

</div>

The server only checks relevance once per server tick. 30Hz server means once every 33.333ms.

Loops are confined to the frame it started in. Meaning if I start a loop in frame 100 it will run until its complete, then frame 101 can start.

Replication of a value (NetFlush, NetSend) happens on the start of the following tick in which the value was set. Meaning, A value set in Frame 100 will be sent frame 101 start.

`for (int i=0;i<100;i++) ServerSetValue();` sets the value 100 times in the same frame. The last value change is what’s flushed on the next server tick.

All replication from the server happens at the start of tick. One shot for each client at server tick frequency.

Client → server updates including inputs & RPC’s are bundled and sent at a defined frequency and always at start of tick.

---

<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:** [December 2, 2024, 10:57pm UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/9 "2024-12-02T22:57:22Z")

</div>

Additional information on Client Send Rates.

See specifically the **Server CPU Usage** section.  
[https://dev.epicgames.com/community/learning/knowledge-base/mo9O/unreal-engine-character-movement-optimizations](https://dev.epicgames.com/community/learning/knowledge-base/mo9O/unreal-engine-character-movement-optimizations)

RPC’s will be bundled in with the Move… `ClientNetSendMoveDeltaTime`

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [December 2, 2024, 11:33pm UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/10 "2024-12-02T23:33:29Z")

</div>

You are trying to do the wrong thing.

First, RepNotify is not a RPC event – it’s a code generation tool that says “when I detect on the client that this thing changes, call this callback.”

If you need each and every event on the server to be mirrored on the client, you should send a reliable RPC event, not try to use replication notify. Sending too many RPC events, and relying on them having very low latency, is still a recipe for a bad player experience, but it will be the closest to the semantic you seem to expect.

Second, if you require anything to be 100% accurate and reliable and fast in a networked simulation, you are doomed to failure. Networks are neither infinitely fast nor infinitely infallible. You should build your architecture around sending commands/inputs as events, and “co-simulate” the same actions on the client, and only use state replication as a mechanism to correct for cases where that fails for whatever reason.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 3, 2024, 1:32am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/11 "2024-12-03T01:32:58Z")

</div>

Hi @Rev0verDrive and @jwatte

Thank you very much for the explanation.  
I was trying to make a pool of objects (of projectiles) and a NetworkManager. (To reduce network and CPU usage)

I thought I could use a single replicated variable for all objects. Obviously I was wrong.  
Now i’m using “FFastArraySerializer” and “FFastArraySerializerItem” for replication.  
This seems to work much better than my previous idea.  
Basically I need replication to trigger sounds and particles on the client side. (“co-simulate”).

Sometimes I feel like an idiot. I’ve been using Unreal for over a year and I still didn’t know that calculations are updated every tick. 🤦‍♂️

Well, this is like the umpteenth time I’ve broken all my code to improve it. The novice circle.

Thank you so much for your help!! ♥

---

<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:** [December 3, 2024, 3:53am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/12 "2024-12-03T03:53:11Z")

</div>

Obj Pools should never be networked. For projectile pools you want to use an Actor Component that manages them. Each client gets one with its own set of projectiles. The server proxies will share a single Server\_ProjectilePool.

Decouple your shooting so that the client does its own thing and handles fx locally for its own shots. Server does its own shot (not replicated) and simply calls a multicast and passes the values needed for Sims to fire their own shot. Server would also multicast hit data.

* * *

Here’s a rough out demo.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/0/240d332c5e621c3d8a30ccf6dfaafe7585cee7cd.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/2/2/b222dcc76a899acce025ea2dfb9ab2c9b5c05275.png)

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 3, 2024, 4:28am UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/13 "2024-12-03T04:28:52Z")

</div>

I will do it as you say.  
The truth is that the replication of the object pool has become a real headache.  
Everything was much easier when i just spawned and destroyed it.  
But the FPS drop was quite important.  
Thank you very much for the explanation and the example code. Highly appreciated!!

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 3, 2024, 5:23pm UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/14 "2024-12-03T17:23:25Z")

</div>

@Rev0verDrive  
Your method works great!!  
I only had to make a few changes to my code!!  
It even fixes a choppy projectile movement issue due to replication in the client side. (No replication no problem)  
It was all advantages!!  
Thank you so much!! ❤

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [February 28, 2025, 8:23pm UTC](https://forums.unrealengine.com/t/can-repnotify-be-faster-or-safer/2160681/16 "2025-02-28T20:23:01Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
