#How to detect mispredictions

1 messages · Page 1 of 1 (latest)

rancid wadi
#

What is the best way to detect a miss predictions and revert their effect on the client (for audio, vfx etc.).

For example in netcode if a bullet collides with a player we display a vfx effect and an audio effect.

We would like to handle these effects in a predicted way (otherwise bullets ricochet off obstacles or players before they get destroyed).

Currently we disable the bullet in the prediction loop, but sometimes the bullet misses on the server a player, but on the client it predicted that it collided.

How do we best reconcile these issues? Ideally we would like to be able to detect that we miss predicted the destruction of the bullet and re-enable it and fade out quickly the audio and the vfx effects, but we currently don't know how this could be detected during re-simulation.

Any advice would be appreciated.

#

How to detect mispredictions

trim patrol
#

Hey occuros, thanks for your patience.

What is the best way to detect a miss predictions and revert their effect on the client (for audio, vfx etc.).
There are two options:

  1. Simply don't. The assumption is: All S/VFX that you are comfortable predicting is, by definition, not server authoritative. Thus, it's often suitable to just let it play out. You'll see this with blood splatter in games like CoD.
  2. If you really must revert it, you'll need to store an ID as part of this gameplay "event", AND have this event replicated (e.g. via GhostFields on a IBufferElementData). Then you can detect if the ID no longer exists when you expect it to (via Update polling), and revert.

We want to improve the APIs available to you around unreliable events like this (which are attached to a ghost, sent in snapshots, and customizable), but we can't commit to when that work will happen.

Currently we disable the bullet in the prediction loop, but sometimes the bullet misses on the server a player, but on the client it predicted that it collided.
How do we best reconcile these issues?
Ah, yeah, "Predicted Despawns" (mirroring "Predicted Spawns") are non-trivial, and are not currently supported cleanly. What you can do, however, is add a DisableRendering component (or similar) to those bullets, rather than adding the Disabled component (which will prevent netcode from "correcting" them, AFAIK).

To detect a miss-prediction, you'd do the same as detecting an incorrectly predicted spawn, which is:

  1. Wait X frames.
  2. If the ghost is still alive, then undo your disabling.
    You could use this logic to also despawn any S/VFX which may have been triggered by this bullet (via GhostId or Entity reference).

LMK if that clears things up, cheers!