What is the right way to make replicated sprinting?

Im interested at creating sprinting system in my game, i know that i can create it using RPCs, but i thing there is more correct way to do it and here is a couple of reasons. First is about network problem, if any or both of server and client is lagging, client will have big problems with moving. Sprinting in 500ms or something, but ive played a lot of online games including ue powered games and even with internet problems i can swap sprint/walk states immediately. Also, character movement component has some kind of movment states: jumping/falling, walking, swiming. So i thought maybe there is a way to create custom sprinting state, because seems like it swaps these states even with network problems. Actually its weird engine has all these states by default but sprint…

Have a look at this video. It’s exactly of what you are talking about.

This seems…somewhat of a hole. Looking through the video is the title a lie? He doesn’t seem to dip into C++ except to showcase some flag or whatnot? The rest of the solution is done in BPs?

I’m confused… :stuck_out_tongue: I need to know this too. To confirm, it DOES look like he fixes it even though there is another bug?

Is this still a valid concern in 5.x?

This follow up video has some more info

1 Like

So…

If I followed along correctly.

The first video is him adding a sprint via a gameplay ability, because the ability-system has access to network replication/prediction (it’s more robust/tolerant). This is a BP-Only solution, and despite him calling out a different bug at the end is a valid solution(?).

The second video is him creating a new movement component in C++ that has a base ChangeMaxWalkSpeed ability as well as a new Dodge ability. Once he creates that custom component, he’s able to access it inside BPs with all the lower-level replication/prediction being applied. It’s a ‘better’ solution because it’s properly enumerating the ability and taking advantage of making a new one.

Those two paths aside, simply calling events across client/server is always going to be lacking prediction, even if a variable is replicated, it won’t be predicted unless we engage that movement-queue either via the ability-system or the custom-component. Is that correct?

I found this video showing how to add your own custom flags to overcome the limit you have with the the default custom flags.

For me I made a dedicated flag for sprint and slow walk and don’t need to send an RPC because I have the speeds for each mode pre configured in the character movement component by indicating a sprint and slow walk speed by default.

For dodging though I still don’t see a way to avoid sending an RPC to indicate the direction, maybe there’s a way you can send some data with the flag but I did test the RPC method for dodging and it seems to be working without any corrections but I bet there’s a way to avoid the RPC.

1 Like

In the C++ video it looks like he takes the LastInputMovementVector (which is a BP node I readily use myself) and applies it to the dodge:

What I really want is to know how to feed it a custom animation so it could be a sprint/sidestep/roll/etc.

EDIT: @Kokapuk → sorry for hijacking the thread but also thanks for helping me realize a solution to a very real problem I never knew I had…

1 Like