Rollback/Resimulation Bug Causing Temporary Incorrect Data for Ghost Entities

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 deltaTime until 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!

Hi Opeth, couple of things that could be cleared up:

  1. Just to confirm, you’re only seeing this behaviour on clients? Is the server teleporting correctly?
  2. Does your queries regarding the teleport functionality include the Simulate tag?
  3. Is the simulator enabled with any sort of delay/packet loss?
  4. You’re saying that the delay value in itself is being reported wrong. Is this during rollback within a frame, or at the end of each frame it has the wrong value? It could be worth figuring out exactly when this is going wrong, and whether it’s being overwritten by the ghostfield from the netcode package or your own systems that’s messing with it.

Hi @jonathan-hertz

Thanks so much for the help!

That was the problem! I realized that I was including the [WithAll(typeof(Simulate))] tag in the job, but when passing the EntityQuery to ScheduleParallel, it ended up being ignored. Once I corrected the query to ensure the Simulate tag was properly handled, the issue with the countdown corrupting during rollback/resimulation was resolved.

2 Likes