Networking & replication questions

Hello !
I’m currently trying to learn more about Networking and Multiplayer.
I start slowly by practicing on the Animation Starter Pack, in this case, the jump replication.

So in my Character blueprint i tried different way to replicate my variable “JumpButtonDown”

Fig. 1

Fig. 2
It works but, are these two ways correct to replicate my variable ?
If so, between tese two images, i don’t know which way is better and why.
I don’t know if the “Shitch Has Authority” node is very important in the Fig. 2 because it’s executed on server. I may be wrong or even not understood the Networking system.

I saw on the internet an old exemple like this too. But i’m very suprised by the use of these two events and i wonder if it can be replaced by the Fig. 2.

I would be very happy if someone could give an answer/hint/solution :).

Thank you for reading.

Kind regards, Waganama

In the second image, I think perhaps that the TellClientStartJump event should be Run on Owning Client rather than Run on Server.

However, if all the clients are supposed to know the state of JumpButtonDown, then perhaps the event should be Multicast.

If you haven’t yet, read my Network Compendium:

Despite that, @Rhynedahll meant the third, not the second image I guess.

You are doing a second “RunOnServer”, which makes no sense, since you are already on the Server.
Doing a “RunOnOwningClient” on the other hand, doesn’t make much sense either.

Replicated variables can only be set by the Server. He has the Authority, no one else. So if you would call “RunOnOwningClient” and then set the Variable,
the Client who “owns” the Character would set the Variable, which would have 0 effect. (For “owning” or “Ownership”, read the Compendium!).

You only need to do the thing you did in the SECOND screenshot. Letting the Server set the Variable and making sure that only he can set it by using the “SwitchHasAuthority” node.
This will make sure the variable replicates to all instances of the Character.

The only thing you might want to add is ALSO directly setting the BOOL on the Client that pressed the button. Why? Because replication takes time and the Client would feel a small lag while waiting for the Server
to set the Variable.

Im already reading your book and i must say that book is very good. Good job!

Sorry, didn’t pay close attention. :slight_smile:

The case that I was thinking of was in the nature of a client doing something that results in an animation, for example “Read book”. For all the other players in the game to see that player do the animation, as I understand it at the moment, the server has to send out a multicast.

This may not be the proper way to do this, but it’s what I have worked out atm and is working for lighting a torch.

While I had looked at your network book some months ago, I went back and went through it again. I think it solved one of my difficulties and I would like to thank you for your efforts and the clarity of your presentation.

I had been trying to use ServerTravel (from blueprints) to move the initiating player to another dedicated server on a different IP and did not understand why all players moved. Until I saw the page on Seamless travel, I had not realized that I actually need ClientTravel. I have not tested this yet, but I am hoping it will work the way I want.

Might I ask if you know if there are any difficulties involved in calling clienttravel from the console?
If so, I will have to look into creating a custom node

First, thanks guys for your answers.

If I understood well, in the second scrennshot, I should link the Remote node to my variable “JumpButtonDown” to avoid lag. If so, I don’t really understand the importance of the “SwitchHasAuthority” node. Server and client will set the variable but only server can replicate, so do i really need this “SwitchHasAuthority” node ?

Or maybe you talked about an other variable. I’m confused :confused:

In all cases, I will read your Compendium. It’s too bad that I didn’t find it before :confused:

No, not after the remote exec. Directly after the PRESSED Event of you Jump Press.

You want to set it directly for the Client who presses the button. The SwitchHasAuthority is to prevent that a Client cheats. He could call the function client side and do bad things.

Wow! This is super useful! Thanks for sharing this! :o

Ok ok I think I understand.
After the PRESSED Event I set JumpButtonDown to true, so on the client Windows I will jump.
And after the remote exec, on the server side, if the server detect I problem, it won’t replicate the movement of the player. Like if the client never jumped.

Am I right ?