I have an issue where the player stutters and does not do as told. I have a video showing the issue and code. Note that it works fine without a second player. If anyone knows what the issue is please let me know! Also I’m new to unreal networking and multiplayer so please leave some baby details if you can. Thanks!
Le video (Ignore music, I was listening to ROR2 ost)
I am not in computer, looking on phone and cannot properly understand your code from the video so, this advice might be wrong. Maybe you are changing values like in every frame while you are running function. I see a timeline there. I know that timelines not a proper function when frame rates are not stable and wavy. You say this only happens with second player. So, maybe you are calling functions from a far bp or something that effects tick rate.
That timeline has been removed and it was used for crouching. Using the built in crouching is good enough I guess. But the running is checked every frame yes. And it’s both players that have this issue. Do you know how else I should change the max walk speed values?
I have ideas, I will be telling you when I am avaliable at pc.
You’re fighting the Server (Authoritative Proxy).
When you make a change to movement (speed, half height etc) the server has to do it as well. Otherwise the server will not agree with your position, movement speed etc. Therefore it will correct.
The SERVER is the Authority over ALL.
For characters using Character Movement Component (CMC) you must apply CMC changes to the local client, THEN rpc the server to follow the same logic that make those changes on it.
DO NOT PASS values to the server to change. e.g. new max walk speed, half height etc.
You call an EVENT on the server. That event walks through logic to determine what speed to set.
In your code you have the following function that sets Movement Speed in CMC.
I also have a function in my character that handles movement speed.
I call this function on the client for every execution that could change the characters speed. Standing +Sprint, Crouch, Crouch +Sprint…etc and so forth.
This function is also called on the server when any of these states are changed.
Simple example… Sprinting
When I apply Sprint on my client, I set an enum, then immediately call an RPC for the server to “TRY” an implement Sprint.
The server “CHECKS” can I sprint then Set an enum. That Enum is a Rep_Notify.
When you set a rep_notify variable it immediately executes its bound OnRep function. I call my speed change function there.
This function is akin to your Movement State function.
So, Apply local… Can I, If so, Change → Call Server
Server: Can I, If So, Change!
@RevOverDrive gives a good idea here, check if his function type solves your problems. Also to give you another doors to go, most of the time when I want to run something on server or client or both, I use Game Mode Override in World Settings with a custom Player Controller BP in it. And I run most of the server/client function in this Player Controller. I’m actually using "Function"s rarely in general.
I did try something like this that takes the input of the shift key and calls the sprintOnServer event. But this for some reason makes my player ONLY spring and stutter when trying to walk. I have no clue if I’m just stupid but this is really confusing me. I just want my player to run when I press shift and stop when I release shift.
So this is correct I just connected the wrong event to the input… My bad.
First off you do not need to use multicast for anything CMC related. If it’s applied on the server it will be applied to all others… except owning client unless its a correction.
Input → Set speed → Call Srv Sprint
Srv Sprint (Run on server) → Set Speed
Done.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.