How to properly reset CMC Network Prediction Data on client and server

Hello,

Our player can attach to some moving objects (controlled by other players, for example). While it is attached, we disable CMC completely (the tick is not working) so CMC is not messing with the motion in any way. This is happening both on the client and the server.

That was working until the recent Unreal upgrades. The Network Prediction Data was introduced.

The time stamps can become desynced after we detach the player and enable CMC on both the client and the server. CMC starts discarding client packets for a while and the player can’t move in the meantime.

It looks like the simple call of ResetPredictionData_Server and ResetPredictionData_Client isn’t enough. There are a bunch of other variables like LastTimeStampResetServerTime in CMC and also in APlayerController.

Is there a way to properly restart this feature?

Also, a note: for some reason, the desyncing issue is easier to reproduce with lower networking lags or even none.

We eventually ended up overriding UCharacterMovementComponent::VerifyClientTimeStamp and forcing bTimeStampResetDetected for a short time. But I wonder if there is a better way to do it.

Hi,

To get a better idea of the problem, I have a couple of questions.

First, I see you’re using 5.6, but what version of the engine were you using previously when the movement was working? I believe the network prediction data has been a part of CMC for some time, so it’s possible some other change resulted in your movement breaking.

Next, you mentioned overriding UCharacterMovementComponent::VerifyClientTimeStamp to set bTimeStampResetDetected to true fixed the issue. Just to clarify, were you seeing VerifyClientTimeStamp/IsClientTimeStampValid returning false after re-enabling the CMC?

Thanks,

Alex

Hi Alex,

>>> First, I see you’re using 5.6, but what version of the engine were you using previously when the movement was working? I believe the network prediction data has been a part of CMC for some time, so it’s possible some other change resulted in your movement breaking.

Yes, I have been patching this issue for a couple of Unreal versions already. Sorry, I can’t remember when it started.

>>> Next, you mentioned overriding UCharacterMovementComponent::VerifyClientTimeStamp to set bTimeStampResetDetected to true fixed the issue. Just to clarify, were you seeing VerifyClientTimeStamp/IsClientTimeStampValid returning false after re-enabling the CMC?

I’m not just setting bTimeStampResetDetected to true but bIsValid too.

UCharacterMovementComponent::IsClientTimeStampValid returns bTimeStampResetDetected as true but bIsValid false because of the client packet from the past or because of the cooldown LastTimeStampResetServerTime.

That stops client movement for a while.

Hi,

Thanks for the additional information!

After discussing this more with the dev team, it seems like we don’t generally stop/start the CMC like this, and this kind of situation tends to be handled by simply setting the movement mode to None. This will disable movement, but it won’t stop the CMC from ticking.

For your use case, it does seem like your approach of forcing a timestamp reset is a reasonable workaround.

Thanks,

Alex

>>> After discussing this more with the dev team, it seems like we don’t generally stop/start the CMC like this, and this kind of situation tends to be handled by simply setting the movement mode to None. This will disable movement, but it won’t stop the CMC from ticking.

Yes, we started from setting movement mode to None but eventually it was easier to turn the CMC off completely rather than dealing with all CMC shenanigans.

I tried setting that movement mode to None again and enabled the tick recently, and one of the issues, for example, is that the character gets detached and does not move with the other object.

>>> For your use case, it does seem like your approach of forcing a timestamp reset is a reasonable workaround.

Ok, thanks.