There's a really cool bug if you are getting glitching

I’ve noticed a few posts where people have seen weird glitching and also where some people had been changing the NetUpdateFrequency back to the default of 100 on the server which is essentially as fast as it can run if you do it on the same box.

It’s all related.

One thing we never tested in the whole course, and I’ve done this myself so many times in the past in projects, is did we impact normal / fast network updates while we were fixing the slow scenario.

I set my NetUpdateFrequency back to default (100) at the end and noticed weird glitching on the SimulatedProxy render.

Looking deeper I could see that you can easily get into a situation where ClientTimeBetweenLastUpdates that set on rep is less than the current delta.

LogTemp: Warning: More-->ClientTimeBetweenUpdates:0.029773 DeltaTime:0.015971
LogTemp: Warning: More-->ClientTimeBetweenUpdates:0.050814 DeltaTime:0.015683
LogTemp: Warning: Less-->ClientTimeBetweenUpdates:0.015683 DeltaTime:0.025609
LogTemp: Warning: Less-->ClientTimeBetweenUpdates:0.015683 DeltaTime:0.022405
LogTemp: Warning: More-->ClientTimeBetweenUpdates:0.015683 DeltaTime:0.015075

this made me think, what else could be happening in that could cause it to glitch

If you look at the Lerp calculation

float LerpRatio = ClientTimeSinceUpdate / ClientTimeBetweenLastUpdates;

When network is running fast you can easily get Lerp over 1 and we are expecting it to be in the range 0 to 1

LogTemp: Warning: Lerp : 0.624599
LogTemp: Warning: Lerp : 1.186011
LogTemp: Warning: Lerp : 0.425377
LogTemp: Warning: Lerp : 0.945676
LogTemp: Warning: Lerp : 0.519020
LogTemp: Warning: Lerp : 1.045300
LogTemp: Warning: Lerp : 0.509386
LogTemp: Warning: Lerp : 1.062835
LogTemp: Warning: Lerp : 0.486592
LogTemp: Warning: Lerp : 0.958095
LogTemp: Warning: Lerp : 0.515371
LogTemp: Warning: Lerp : 0.978642
LogTemp: Warning: Lerp : 0.473229
LogTemp: Warning: Lerp : 0.934854
LogTemp: Warning: Lerp : 0.506144
LogTemp: Warning: Lerp : 1.010249
LogTemp: Warning: Lerp : 0.443185
LogTemp: Warning: Lerp : 0.968124

I was really lazy and tried clamping lerp in that range thinking that the max of 1 means were pretty much where we want to be as won’t make any visual difference.

float LerpRatio = FMath::Clamp(ClientTimeSinceUpdate / ClientTimeBetweenLastUpdates,0.0f,1.0f);

Now it runs really nice with the server updating at a frequency or 1 / sec or as fast as it can.

I’m also running server time in the getmovement component which auto synchronises (best it can) between server and client rather than the local time which you probably won’t notice on a local test box but def would in real world.

Move.Time = GetWorld()->GetGameState()->GetServerWorldTimeSeconds();

If I was going to fix it for real in a prod environment I’d think harder about the code and so some fancy refactoring :slight_smile: but clamping works good enough for now!

Hope this helps someone if they notice glitching near the end.

5 Likes

Wow I never thought about testing the stuff you tested. Thank you for this and thank you for helping me become more aware in testing stuff.

Privacy & Terms