Server see client moving but client go crazy

Hello,

I’m stuck please help me to understand -_-

When I try my multiplayer project I got a problem on the client side (my friend PC)
The server see the client moving as well (when the client use inputs). All is ok on this side (spawn, moving, collision etc…)

But

For the client, all is shaking on his screen. he can move (but not using the PlayerController shortcuts for menu) but all go crazy.

I don’t understand why. I set all the event from server and do the same for spawning actor.

I found my problem but I’m looking how to solve it -_-

When my client join the game it spawn another server… (So I got 2 players (real life guy ^^) with two server + 1 client

I try a lot of time and when the client load level properly, both player can play together without problem !

It almost done ! please help ^^

I try a lot of time and when the
client load level properly, both
player can play together without
problem

Hi, if you use an RPC (Run On Server, Run On Owning Client, Multicast), then if you do not make it reliable, then it might be dropped due to network bandwidth problems, so the event might not execute. So if the RPC must come through, then make it reliable.

But do not make everything reliable since the RPCs only get dropped when you have network bandwidth problems. So something like an event to spawn the client → reliable since it breaks the game if the client does not initialize correctly. But something like spawning a particle system on Multicast → the game will also continue without it, so not reliable.

And if you want to see where your network bandwidth is going: Using the Network Profiler in Unreal Engine | Unreal Engine 5.3 Documentation

Thanks a lot for reply.

I actually only got reliable on the spawn event and on the vehicle(pawn) inputs. I’m going to try without reliable on the pawn

it work ! Nice tips man !

But it’s laggy on client… Let’s try to fix that now :stuck_out_tongue:

Tell you if all is ok later !

Yeah, my main problem was to find why the client can’t play lol.
Now, he can play but client got “lags”. it’s playable but not comfortable.

When I try it in editor and not with two different PC, it’s laggy too. If I make the pawn reliable all is ok with the two editor windows (client & server). But, the first problem I got come back again if I package the project and play with two PC…

Hmmm, if you’re events already are reliable, then making some of them unreliable should not solve this… :slight_smile:

Make sure that you’re clients are initialized before calling “Run On Owning Client” or “Multicast”. Cause after the server spawns a replicated actor it first needs to be replicated to the clients before it will exist on the clients. If you would call “Run On Owning Client” before then, I’m not quite sure whether or not it will execute the reliable event since the actor does not yet exist on the client. If it’s an unreliable event then it surely won’t execute, but I don’t know about a reliable one. But this might something for you to check.

Making some events unreliable that previously where reliable would reduce the network bandwidth used up and therefore the actors will be faster to replicate to the client and that might have apparently solved the issue, if this was the issue.

Ok you right for the initialized thing ^^

Now I have to make what you say but I don’t know how to initialize correctly. If you know a documentation about that, I will love you forever xD

I don’t know if there is any documentation specifically for that.

One thing you could do, is when you spawn it on the server do not use a “Run On Owning Client” event afterwards, but instead in the event begin play of the newly spawned pawn you check if the “Get Player Controller” with index 0 equals the controller of this pawn. Since “Get Player Controller” with index 0 will always return the local player controller, this would only return true if the controller of the pawn is executing it. So if it returns true, then execute the logic you would else execute after the “Run On Owning Client”.

The event begin play gets executed by any client once this actor has been created on it. So therefore you do a check if the client executing this code is also the controller of the pawn.

Else you can also set variables to be “RepNotify”. This will create a function which will be executed on the clients after this variable changes on the server. So this function gets called after the change has been replicated to this client.

So nice… I “half fix” before your reply.
I try my project with friends. One got a nice network so we can play together and the game is really smooth on client and on the host ! :stuck_out_tongue:

I just added a gate close before the multi cast on the pawn blueprint with a delay on “Do once” that open the gate for tick events.

I think it work with my friends cause he got the time before the delay end ! But for my other friend with less network it’s bugs sometimes.

I will try your way ! it seems cleaner like that.

Thanks again !

Ok ! Now all working !

You helped me so ! you can try the first version here :

You should ask to a friends (it’s playable with 4 players for the moment I think… I only try with two only) gamepad is better !

Tell me what you think. Appreciate that :wink: