# How does CharacterMovementComponent handle resubmitting multiple lost moves?

**URL:** <https://forums.unrealengine.com/t/how-does-charactermovementcomponent-handle-resubmitting-multiple-lost-moves/487831>\
**Category:** Multiplayer & Networking\
**Tags:** Replication, charactermovementcom, rpc, unreal-engine, Multiplayer, question\
**Created:** [August 22, 2021, 6:03pm UTC](https://forums.unrealengine.com/t/how-does-charactermovementcomponent-handle-resubmitting-multiple-lost-moves/487831 "2021-08-22T18:03:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![galact1c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@galact1c](https://forums.unrealengine.com/u/galact1c)\
**Post date:** [August 22, 2021, 6:03pm UTC](https://forums.unrealengine.com/t/how-does-charactermovementcomponent-handle-resubmitting-multiple-lost-moves/487831/1 "2021-08-22T18:03:31Z")

</div>

I’m trying to understand how this part of the CharacterMovementComponent works:

> The system for buffering saved moves  
> already ensures that movement  
> information lost in transit will be  
> resubmitted and evaluated. This  
> provides a similar safety net to a  
> reliable function, but without the  
> risk of overflowing the reliable RPC  
> buffer, and with added provisions to  
> make sure movement data that is too  
> old gets discarded.

[(From CMC docs)](https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/CharacterMovementComponent/)

* * *

`UCharacterMovementComponent::ReplicateMoveToServer` appears to find the oldest (unacknowledged) important move and send it alongside NewMove whenever NewMove can no longer be delayed.

Then, in `UCharacterMovementComponent::CallServerMove`, the old move is sent to the server using `ServerMoveOld`.

My question is: what happens when there are several old moves which need to be sent? What looks to be happening is that a single old move is sent right before the next new move.

I want to understand what happens when multiple consecutive moves are unacknowledged and if it is possible for there to be a chain of moves like this:

Move 1 (acked) → Move 2 (not acked) → Move 3 (not acked) → Move 4 (acked)

---

<div class="post-metadata">

**Author:** ![JoeProgram](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/joeprogram/32/872486_2.png) [@JoeProgram](https://forums.unrealengine.com/u/JoeProgram)\
**Post date:** [May 20, 2023, 2:37am UTC](https://forums.unrealengine.com/t/how-does-charactermovementcomponent-handle-resubmitting-multiple-lost-moves/487831/2 "2023-05-20T02:37:24Z")

</div>

Even though this is an old question, I’d love to know more about this too. I’m still learning Unreal and C++, but here’s what I believe is true:

1. Since there’s no guarantee with [UDP](https://www.avast.com/c-tcp-vs-udp-difference#) that the moves will be sent, or will arrive in order, I don’t think this system guarantees every move will eventually make it to the server. Like in `ServerMoveOld_Implementation()`, line 8501, it’s possible for a move to be older than the server’s version of the world, in which case it’s just discarded with a log warning.

_Line Numbers are from looking at the code in Unreal 5.1.1, in case there are differences between versions_

1. So OldMove is more like an imperfect safety net, giving a move additional chances to be processed, rather than a orderly queue where everything will be processed.

2. In Ryan B’s post on [“A holistic look at replicated movement”](https://forums.unrealengine.com/t/a-holistic-look-at-replicated-movement/265041), Ryan mentions:

> _Side note: When the server receives a ServerMove, the client has sent it a ClientTimeStamp. This is the value that the server looks at to calculate what deltaTime to process its PerformMovement with. Why? Packets get dropped. Every ServerMove() a client sends isn’t going to get to the server on time, or in order, or ever, so it’s meant to handle those cases. If there’s been a major mess-up with the packets in transition, it’ll likely lead to a correction being sent, since now information will have been lost. If Move 1 you were moving forward, Moves 2-9 were moving to the right, and then Move 10 you moved forward, if the server received Move 1 and then Move 10, it would simulate that entire Move 1-10 time as if you were holding forward the entire time, and be way off. No avoiding that._

Which I believe is why, when an OldMove is selected, the system tries to pick one that’s significantly different from the last acknowledged move (`ReplicateMoveToServer()`, line 8141). If moves are similar enough, it doesn’t matter if some of the middle ones don’t get through, since it will apply the move to the whatever time has passed since the previously acknowledged move _(such as in `ServerMoveOld_Implementation()` line 8501 where it assigns a value to DeltaTime.)_

1. If different moves do get backed up, there’s still a chance for old moves to all come in order. Since `ReplicateMoveToServer()` is called from `ControlledCharacterMove()`, which is called from `TickComponent()`, there’s a chance to submit moves over and over. If an OldMove happens to get to the server and is acknowledged, but the new move happens to be dropped, the system would advance to the next significantly different OldMove and try to send that on the next `ReplicateMoveToServer()` call.

This is just my guess, but by looking at this design, I’d think it’d work well if:

- Moves get through much of the time, and only generally need an imperfect safety net to help with dropped packets.
- Consecutive moves are often similar enough that dropping a few doesn’t matter much
- Moves are usually processed quickly, keeping the significantly different moves in the queue short, to avoid the very situation you’re talking about.

Would love to hear from others more familiar than I am!

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [May 20, 2023, 6:31pm UTC](https://forums.unrealengine.com/t/how-does-charactermovementcomponent-handle-resubmitting-multiple-lost-moves/487831/3 "2023-05-20T18:31:51Z")

</div>

That’s a pretty solid interpretation and walkthrough. Well done.

Overall the system is not designed to make bad connections work well. If ping/jitter/loss is all over the place on a users connection, well that’s on them. There is network smoothing to help ease corrections/latent moves. Anything more is bloat and overhead.
