Hi guys, I’m a bit of a noob in UE5 and I’m trying to learn how multiplayer/networking works. I’m trying to get all player characters to be able to sprint while holding the shift key. I set up the logic in the PlayerCharacter blueprint by creating 2 functions - one called “Start Sprint” and one called “Stop sprint”. Start Sprint just sets the Max walk speed of the Character Movement component to a higher value and Stop Sprint just sets it back to base value. I then call Start Sprint when shift is pressed and Stop Sprint when shift is released.
It works fine on the server side but it does not work on any of the clients. I tried making the variables replicated but that didn’t work. Can anyone tell me how I can go about accomplishing this?
Hello, it all depends how you set up the whole logic. Generally to let you understand basics, client in most cases is following server. So if you call function “Start Sprint” on client and it’s not replicated to server, nothing will happen, as character will run with the same speed on server (so even if client is faster now, it will still follow server speed).
Now how to solve this, for example you could change these 2 functions to events and make them RunOnServer. Then even if they are triggered on client, logic will happen on server and then be propagated to the client.
Hey there @SideshP! Welcome back to the community! Sitiana is correct, due to the way replication works, you’ll need to make sure both the server and the client know the correct speed. In a normal implementation, you will only be sprinting on the local client and the server has no idea you are meant to be moving that fast. Here’s a tutorial to help correct that!
Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.