Second Player Not Responding To Functions

Here is a video documenting my issue: - YouTube

I have been working with networking a bit lately but it seems not matter what I do, I can’t get the second player to do anything. I have tried creating a pickup item script but the only way the item could be picked up was if the server was doing it. I have now attempted to make a very basic sprinting script. This, once again, works perfectly fine on the server but on the client it does nothing.

I have a feeling that each variable I change is only effecting the servers pawn but I don’t know how to change this. Here is my basic blueprint based on the third person template.

Here I have a repnotify function activated on left shift press. This then triggers the sprint function

25806-capture.png

I am simply changing the max walk speed based on some constants. For this, I am using the switch has authority to ensure the client isn’t cheating. I have tried applying the remote node to the branch as well but it does the same thing.

I am probably missing something simple but I can’t seem to work it out. Thanks in advance for any help.

EDIT:
I would just like to mention I have tried the basic movement script that has been displayed by so many people where I basically just run the CharacterRun function with no switch authority and no RepNotify but that too appears to produce the same results.

25878-capture_03.png

I have noticed however that if I remove the switch from the run function, the client will print “Running” and “Walking” but the movement speed does not change. It still works on the server.

Replication only works one way: Server → Clients. The clients do not replicate information back to the server, so setting a replicated variable on a client will have no effect on anyone else in the game. This is why your RepNotify is not firing when you sprint on the client, because the variable is only changing on the client and is being dismissed by the Authority switch within the RepNotify (because its executing on a client).

In testing stuff while making the screenshot below, I also realized that you can’t really use a RepNotify in this instance, because whenever the server or client presses shift, it’ll make both the client and the server sprint.

When the game is running, each player has a copy of all characters in the game. You can easily see this by doing a Get All Actors of Class and printing their display names on a keystroke.

The Server has Character 1 (himself) and 2 (his client’s character). The Client has Character 3 (himself) and 4 (the server’s character). When you change a replicated variable on the server, it will change it on Character 1 (himself) and then make its way back to the client, at which point the client will change that variable on his character (3).

The solution is to not replicate the variable, but ask the server for permission before we change it. This is how you can accomplish this with replicated events:

When anyone presses Left Shift, it asks the server (Run on Server) to set us to Sprinting (if we are already the server this still works, it just executes on itself). The server then takes over and checks if he has authority (this is redundant but w/e). He then tells the client (Run on Owning Client) who first asked him to set the Running variable to True.

This has the effect of only changing the variable on the local character of each player, but while still confirming the variable change through the server.

Thankyou for your detailed response and I did learn a thing or two from it however I would to point out that the client still does not run. This works perfectly on the server but just won’t work on the client.

I’ve edited my answer to include more details as well as a video documenting my issues.

It’s quite possible what I posted still doesn’t work since I only tested using print string :stuck_out_tongue:

The video is private btw

Hey guys, i wanna join This conversation. Cause i fightng with the same. At. Iam in Holidays, but i try to gonna check This soon. Thx for the Nice explanation.