Hi everyone,
I’m encountering an issue with Netcode rollback (Resimulation) where the countdown for a teleport request becomes corrupted for a few ticks before correcting itself. Here’s what happens:
- I create a ghost entity request that holds the actor, the teleport destination, and a delay.
- Initially, the delay is set correctly, and during each frame, I decrement the delay by
deltaTimeuntil it reaches zero, triggering the teleport. - However, after a few frames, the delay starts snapping and subtracting large, incorrect values, which causes the teleport to happen prematurely. A few ticks later, the delay returns to the correct value, and the countdown resumes normally.
- This leads to the actor teleporting twice—once prematurely and then again at the correct time—causing visual glitches.
Initially, I suspected a deltaTime issue, but after testing, deltaTime remained consistent, as expected since the simulation is running within the PredictedFixedStepSimulationSystemGroup. It seems like rollback/resimulation is temporarily assigning incorrect data to the delay, but I haven’t been able to pinpoint the exact cause.
As a workaround, I added a non-GhostComponent to store the tick at which the request entity spawns and the initial delay. Each frame, I correct the delay by using this formula:
Delay = InitialDelay - ServerTick.TicksSince(SpawnTick) * deltaTime
It’s worth noting that this bug occurs about 7 out of 10 times and becomes more or less frequent depending on the network ping.
Thanks!