Network Overload

I am creating a multiplayer game and i just turned on the emulate network setting and my game is kind of falling appart, good news i found the source. Its a multicast funtion that is being fierd every time a player shoots, to replicate animation, sound and fx. When this is used, after some shots, the player looses his ability to shoot and no RPC events are called. If I remove this function and only do the line trace function, which is run on the server, nothing breaks and the player is shooting every time he or she presses the button. Now my question is: How do i optimize this, so it doesnt break the whole game, but still, I need to replicate shooting animation, sound and barrel effects so i cant remove the multicast funtion, because the game wouldn’t look nice at all. My theory is that the multicast is using all the network and making it so no other events can be fierd.

Thanks for your time and effort, best,
Chippy.

Your shooting mechanics are bit overloaded and you’re broadcasting way too much. Thus saturating the network… bandwidth limits.

  1. Firing client shoots a local only shot. Said shot mechanic handles all the fx on the owning client.
  2. Firing client sends an RPC to server noting it fired.
  3. Server receives RPC and fires a local “Authoritative” shot.
  4. Server multicasts to Simulated Proxies (auth shot target point for local vector calculation).
  5. Sims execute a “firing” event that handles simulated shooting (projectile, fx etc).
  6. Server multicasts hit location of auth shot to sims (vector). Sims handle the fx at vector locally.
  7. Server handles dmg, destruction events etc. RPC’s hit client for hit fx.

IF using hitscan for shooting bundle #4 and 6 together.


You need specific events with defined functionality to handle each type of proxy firing.
Autonomous (owning client), Simulated (You on other clients sim), Authoritative (server proxy of you).

I have specific functions to handle firing by each of these proxies. Autonomous Firing, Simulated Firing, Server Firing. Each processes FX such as audio, particle, montage etc. Each also uses a specific projectile that’s configured for task.

Thank you for your reply, do you mind showing an example? I am not new to unreal engine but i am pretty new to networking, worked with it for 10 months now and i coundn’t imagine that this problem would happen.

best,
Chippy


here is my current code by the way :slight_smile:, the regular attack is being fired of player input. Even when i remove the play impact fx, after 30-40 seconds of firing it stops and I can’t shoot anymore, only for the client tho. In the network profiler, those events take max 20 bits, only the impact fx taking 200+

Here’s a simplified structured.

How it’s structured in my graph.

Enlarged version…

Autonomous Proxy Firing (Owning Client)

Authoritative Proxy Firing (Server)

Sim Proxy Firing (versions of “shooter” on other clients)
Then 0 is proprietary logic… not needed for this example.

Thank you, you are a life saver. I am going to look into your code, and just to clarify, the way I did it was not right and brigs lag and clogs up the bandwidth. And this way you shared now should not clog up and get RPC’s dropped?
Regards,
Chippy

My test projects for prototyping these things runs at default bandwidth settings. I’ve tested this thoroughly. This code only sends the small data needed to fire a shot in the right direction. There’s 10x + more in movement data in comparison. The functions themselves handle all the fx and animation. No need to rpc any of that and you shouldn’t ever rpc those types of assets in any case.

Did I understand you right, I shouldn’t RPC’s to fire. Bro I’ve been lied to all this time. Would all this get replicated tho? Thank you a lot, I’ve learned stuff, let’s just implement it in my project now… hehe. Shouldn’t be a problem though. Thanks. But I see that you are using projectiles, how would this work with line trace?

You don’t RPC animation montages, muzzle flash fx, shot audio. You RPC small data (bools, floats, vectors, enums etc). These values are used in event functions to “determine” new states and actions. Said actions and states execute functions that play montages, fx and audio.

Look at my code. At no point am I passing any montage, audio or fx through an rpc.

Think “DETERMINISTIC” and code that way.

If I pass a boolean the receiving function does action A if True and action B if false.

Replace projectile spawning with traces. Same principles apply.

Okay now I get what you are saying. You saw the code I sent? If not I can send again it’s not a problem, however, I was just calling one rpc with no inputs, still it would get clogged, is that because I didn’t use autonomous, authoritative and sim as you used in your code?

Need to see your attack input logic flow.

It’s just a left mouse button event and then I call the regularAttack.

Then it’s pretty clear that you don’t have any logic limiting the execution of the events.

For example “Play Anim Regular” should only execute logic on Simulated proxies.

e.g. If you fire, then the sims of you on other clients should only execute the montage.

There’s nothing in the logic to exclude any other client or server proxy from attempting to execute the montage.

See my example in posted pics.

Get local Role == Simulated Proxy [Branch] (TRUE) → Execute

This stops all other characters from executing. Only representatives of me on other clients should execute.

Furthermore, servers should not be executing logic for FX. Audio, particle, decals etc. Servers DO NOT render, nor have audio capabilities.

Servers for the most part are math engines and the game world is only made up of collisions.

Here’s a flow logic outline for hitscan.

You’ll be better served if you pass the servers “hit location” to the Multicast Shot Fired event, then on to the simulated proxy fire logic. You can then do your sim trace from muzzle to auth hit location. Properly place hit decals/fx etc on clients.

For greater client → server shot accuracy you should pass the clients trace start and end vectors to the server (Server Proxy Fire). The server can then scrutinize the aim vector and compare against its own start/end. If the margin of error is extremely low and angle is legit you can use the clients vectors. Otherwise the servers.

1 Like

Thanks bro, I will get back if anything goes wrong. But you have explained it very good and clear, so this should be butter smooth. But also, if I am using listen server, is the server gonna be able to fire, or what’s the reason for the authority check?

In some scenarios the input can execute on both client and server. The authority check ensures it’s not the server executing the call, but an actual remote client.

Yes, there’s an explicit call to the server.

So I used this code, and it’s working for the clients, not the server, the server always returns false when doing a “IsSimProxy”. Any soulutions?

UPDATE: I added an authority check and if we are authoritive we play anim montage, this seams to work for everyone, is this the right way to do it?