How to customize character movement with proper network prediction?

Hi guys. My game, which is mostly C++, uses CharacterMovementComponent. I also have some additional movement stuff in the game for doing a dash in a specified direction. Up until now, I’ve been performing the dash by replicating an event from client to server which then causes CharacterMovementComponent to temporarily enter a custom movement mode. In this custom movement mode, the dashing movement occurs. After enough time has passed, the movement mode returns to MOVE_Falling.

It works fine in single player, and it almost works OK in multiplayer in a low latency environment. However, it doesn’t work well at all under high latency or with packet loss/reordering, because there is no proper prediction/rollback/replay occuring. I can easily see this by setting p.netshowcorrections 1 and looking at the mispredictions and corrections whenever a remote player dashes. Of course, it’s also visible due to the messed up character movement. This is what I would expect it to do, because there is no way I’ve provided enough information to the engine about how to apply inputs when doing prediction/prediction/replay.

I’m at the point now where I can’t continue using this hack, and I need to implement proper prediction for the dash movement.

I first looked at the API documentation, but it seems like there is not any documentation about how to do this. I also looked at some of the example projects, but none of them had network-aware customized movement. Finally, I looked at the UnrealTournament source, and its implementation of customized dodging and etc. movement. I was able to see parts of what to do – subclass UCharacterMovementComponent, FSavedMove_Character, etc. However, there are not many comments in this code explaining the big picture or how it fits together. Also, it seems there is overridden + copy-pasted code from the base engine with just a few tweaks for what UT needs to support (due to lack of base engine supporting certain things), so it’s hard to tell what I need to change for my own game and what I don’t.

I spent a bit of time on it and couldn’t figure out what needs to be done. I realize every game with customized movement is going to be somewhat of a specialized scenario with its own individual needs, but I was hoping someone with more experience in this area of UE could help me get an overview of what needs to be done to add customized movement to CharacterMovementComponent that has proper network prediction. It doesn’t need to be perfect – just enough to get me started and a general idea of what to do in the context of UE. Thanks!

Bumping your thread because it is relevant to my interests. I would love more info on proper prediction as well, though my case is a step weirder because I’m not even using a Character… it is a plain ol’ pawn which has so little built in network support.

Same here, I’m not even using a character as well (just a pawn) and my own network predicition is not even close to poor, it’s basically non-existent…

I’ll throw in my support for this thread as I am also trying to get client-server replicated movement going for APawn. I decided to use a custom version of UFloatingPawnMovement, but it doesn’t give me much except for a dumping ground to put all my movement code. I am at a crossroad where I am trying to decide whether to add the INetworkPredictionInterface to my custom movement component and do it all myself, or just use ACharacter with UCharacterMovementComponent.

I was hoping that I wouldn’t have to do so much low-level network coding, but ACharacter is so heavily biased on bipedal humanoids. I’m flying starships and I’m not sure how viable it is to override ACharacter to adapt it for starship meshes instead.

100% agree on there. I DID try to just make a character and use its CharacterMovementComponent, but the “restrictions” to human pawns (like the capsule component) were way too annoying for me, just an enormous amount of overkill and that isn’t even a “workaround” anymore, that’s just so ugly… I didn’t want to keep such a huge mess on my pawns :frowning:

It’s been a while, so I’d like to propose a deal: someone at Epic (with knowledge of this subject) gives a few pointers on how to get started with what I’m trying to do, then I’ll take it from there and write a full wiki article and tutorial on the subject to share with the community. I think customizing movement with working network prediction is going to be a prerequisite for many networked multiplayer games made with UE4.

Bump, custom movement with prediction/correction is very important and shouldn’t be tied to Character.

I have to work out a way to do something similar.

Did anyone achieve something on this topic?

This looks nice:

Old post, but this is a very good document about CharacterMovementComponent internals

Also this video tutorials are very good and definitely will help you