Is This Lag Usual?

Hello everyone,
I’m new to networking of Unreal, and i’m kinda confused about certain things. This is what i’ve been experimenting with:

When Client launches itself using a (Run on server) Replicated function, there is a noticeable lag once it happens. By my understanding of ue4, what happens is that client sends a request to the server to launch, and the server responds back. I know sending in and out of the server takes time but what confuses me is that this is the only network function i’m using and it’s slow…

This approach to launching character is probably not correct, So i wanna know what to do for such important gameplay elements that should happen instantly…

What I would try first is using a Print Text function in place of the Launch Character to make sure it’s actually executing in a timely manner and the delay you’re seeing isn’t just something quirky with the Launch Character node.

Are you experiencing this lag while playing in the editor?

I just made a simple FPS using C++ and everything is instant and fine with client movement no lag at all, its only with this launch node. tried the printing you mentioned as well and it works fine.
by lag i actually mean some kind of a jittering, like the player wants to jump for a moment, but stops for a fraction of a second and then does it…

This is a great question - and you are totally correct that the server should be authoritative for key gameplay elements like movement and death.

But as you experienced, you need to jump on the client for locally controlled characters as soon as the button is pressed or everything feels laggy and wrong.

So the general approach would to start jumping on the client immediately, notify the server, and then reconcile the position overtime.
When the client and server are out of sync, the best approach is to reconcile this difference overtime (error correction.)
Client-side prediction helps minimize this error, but it is difficult to get to work in all conditions.
All this is difficult and hard.

That being said, the great thing is that the Character movement component already has this client-server networking built-in.

Thanks Epic!

So all you really need to do is call jump on the locally controlled character on the client, and also things like AddMovementInput.

For your other key gameplay conditions like hitting and dieing, you need to manually replicate and keep server and clients in sync yourself.

:slight_smile:

That seems to be the right thing thanks!, but i’m not sure what i should do for reconciling you mentioned. can you clarify ?

Sorry - my prior post was too verbose :wink:

For the built-in supported CharacterMovement functions like AddMovementInput and Jump you don’t have to do anything. (Client-side prediction and reconciling error-correction is built-in)

For your own gameplay events, you will need to make sure to fire them on the server and then replicate that to all the clients. ( You don’t need to implement predicition or error-correction for many simple conditions)

Thanks, this helps me a lot to understand the networking
What do you think about this:

It fixes the responsiveness, but if i repeat the launch mid-air player stops for a very very small fraction and then continues… how do you think i can improve the image above?

btw, this gdc talk is been very helpful for me as i’m watching it right now. thought you might find it helpful as well. I Shot You First: Networking the Gameplay of HALO: REACH

So, if I can help, many client/server interactions are already covered under the movement component. On the actor you’re looking at, there will be a “replicates movement” checkbox. Ticking that will handle synchronizing the movements of the actor between client and server.

Now, I’m not certain what exactly is covered by “movement”. I don’t know if it would cover the “launch character”. I know it will cover uses of “Add movement” and I believe it will cover rotation. I would love to have clarification on that as well.

I believe, once checked, you do not need to specify that it needs to run on the server. For example, if you had a “W” input mapped to “Add movement” on the Y axis, I think all you need is that one node. I don’t really know how it is handled internally though.

Yea i have my movement replicated by sadly it doesn’t include Launching, since i wanted to use it for double jumps.
Althogh i think there might be a way to use built in jump function for mid-air jumps but i wanted to solve launching problem to learn more about networking…

what do you think about my last post’s image? it solved the delay but yet has a jittering for the next mid-air launches, do you think i can improve that?

The best approach to double-jumping is to extend the existing character movement jump using c++ - here is a great example:

Happy Coding :slight_smile:

I hardly know anything about networking, but my wild guess about your mid-air player stop is that, you are actually launching the character twice. One you are doing right away with your node, other one done by the server. Ofcourse server is a little late and it re-launches your character, which is the reason you see a mid-air stop.

But then I can be completely wrong.


From my point of multiplayer game experience, what you need to find is the way to launch character, THEN tell the server to replicate your movement. So that the jump will look instant on your side while others will see it as a small delay. This is what happens in most games, such as World of Warcraft.

If only it was that easy ( actually it is that easy with Jump, since it is directly supported by the networking in CharacterMovement Component.)

Alas, I don’t think Launch is supported by the built-in CharacterMovement replication. Your approach of firing on both the client and the server is basically #3 in:

It is probably the best approach without resorting to #4 which takes more effort.

The jittering your are seeing is possibly error correction? Although it should not be too significant. (Are you running with lag?)

Can you maybe post a movie?

If i don’t launch the character on the server, when i press c the clients shakes in its place for a moment and stops. which i guess is the result of being ignored on the server side.
Seems like any new action you add to your character that is not MovementComponent(or any built in network) related should be confirmed on the server…

Yea i could override jumping, but i wanna do this to learn networking stuff or even i might someday use launching in network for other reasons.

Sadly my upload speed is horrible, it takes ages to upload a video; if you wanna see how the lag is, just make a launch node after pressing a button and test it on client. what happens is the same as happening mid air for me ( a bit less extreme ).

Okay so I made some tests myself so I was worried about this problem for my own future plans.

Now here is my setup which completely works fine on my end. I made this work on Content Examples - Networking map. Here is the controller:

So far there is no delay, not on the server, not on the other players. Maybe you would like to check that out. ^^

The main difference between that one and your first blueprint is the z-override which replaces your z velocity instead of adding to it. That is probably giving you the “double-jump” effect you are looking for.

However, only firing on the server may work if client and server are on the same machine, but when you introduce latency it will feel laggy and non responsive.
Are you testing locally or over the wire?

If you are only running on the same machine, you have zero latency and will not experience a noticeable delay.
But you can simulate latency locally using:
https://www.unrealengine.com/blog/finding-network-based-exploits

Alternatively, you can run the editor from a remote machine and connect remotely.

Or you can package a build and run it remotely.

In any event, testing network stuff is a pain

:slight_smile:

Thought I would mention how easy it is to test simulated lag locally:

Make sure to be running from editor 2 player, dedicated server.

On client, open console with ~

enter: Net PktLag=100

This will simulate 100 ms latency on wire.

This way you can feel the delay of the jump when comparing server-only launch vs server and client launch.

First of all I am not the guy with the problem, I think you confused us. :stuck_out_tongue:

The override was just a test, I still get good responsive result (0ms) with or without it and there is no shake. As I said, the mid air shake is probably happening because he had two Launches, one self, other one the event doing which server replicates to everyone again.

He also mentioned a delay for the client who launched himself aswell despite the fact that he is playing in the same computer. What I tried here fixes that as far as I can see.

You are correct that there is no mid-solution for this. What you see at your screen will always be replicated with a delay depending on the latency. World of Warcraft, League of Legends, those games suffer tremendously about it but it’s not something we can help.

What worried me was seeing the delay on myself aswell but didn’t happen. Maybe this fixes the problem for the op aswell.

Thas my 5 cents. :stuck_out_tongue:

Your Z value is low, try increasing it to something like 800 and try it a few times mid air ( especially when falling down ) and then you may see hitching.
Also, what was that casting you did? never seen a cast without execution. how do i call it?

So i applied Pktlag (delay) for 100 and 200ms and results were inconsistent, sometimes like before but often with larger teleportation distance… ( obviously due to the delay )
I even tried playing unreal tournament 4 with 180-200ish ping and used the double jump power up, and it was pretty smooth! i don’t think they used launch tho :smiley:

On my side there was zero hitching. I even tested it with 2 clients and 1 server. This setup I have done is in controller. And in order to get that casting, just cast to your pawn’s BP, the right click upon the cast node, it got an option “convert to pure”. You don’t need it right now here though. :stuck_out_tongue:

Anyhow, not sure how else I can help. I am happy to see no lag at all (obviously this is 0ms), at least no hitching. Hope you can test it out yourself aswell.

I want to add that Net PktLag=100 is not a good way to test it if you are on the same machine as a server and client. Because it seems to add a lag to client aswell which shouldn’t happen. Whatever you do meant to be instant on your end (on your screen/game) while the replication should be delayed depending on your ms while speaking with the server and the other client’s connection with the server again.

So in the end, 100ms is huge. :stuck_out_tongue:

This is how it should be done for multiplayer. Button press on client execution on server reliable replicated back