What, specifically, gets rolled back when re-simulating in the Prediction group?

I have a DynamicBuffer populated with a collection of projectiles the player is allowed to throw. In the Prediction group, if I detect that the player has pressed the Throw button and has Entities in its Throwables buffer, I remove one and convert it into a projectile. I keep running into weird buffer indexing problems that I believe are related to re-simulation during prediction reconciliation, though…

Does the state of a DynamicBuffer attached to Predicted Ghost get rolled back when resimulating? If it doesn’t, what else doesn’t? In theory rollback Just Works in Netcode for ECS but it seems like maybe there are limitations on what state can actually be rolled back?

Hi devook,

Yes the DynamicBuffers state will be rolled back when restimulating as it forms part of the ghosts state which will form part of the snapshot. It sounds like you have a buffer of entities in your throwables buffer, this might be the cause of the issue if those entities are Ghost Entities (ad they will also be rolled back). You might be best using Predicted Spawning instead. Although it hard to say without more specifics on your particular use case.

Thanks,

Sam

I’d love to use Predicted Spawning here and have attempted to read the doc you’ve linked before, but it’s totally inscrutable to me. If I want to “use predicted spawning,” what baseline steps do I need to take for that to nominally work? The example code under "Implement Predicted Spawning … " simply has a comment in it that basically says // Code for predicted spawning goes here. Not particularly useful!

It should be as simple as spawning the entity in the prediction loop on the client in response to the input (as well as on the server). See PredictedGhostSpawnRequest If your entity is setup correctly it will be baked with this component and when spawned on the client it will be linked to the matching entity on the server when it starts to receive snapshot data for it and update as if it was server spawned. Instead of your client seeing the snapshot data for a new object and spawning it it just sees the snapshot data as new data for the already spawned object and applies it as it does to all other ghosts.