space-wizards / space-station-14

A multiplayer game about paranoia and chaos on a space station. Remake of the cult-classic Space Station 13.
https://spacestation14.io
MIT License
2.45k stars 3.05k forks source link

Make guns hitscan with projectile effects #16807

Open metalgearsloth opened 1 year ago

metalgearsloth commented 1 year ago

Mirror mentioned it, worth a shot.

Pros:

tom-leys commented 1 year ago

Rng could be server-synced, i.e a RNG component in the gun that stores & network syncs the seed and so ensures both client and server get the same next value for accuracy. Requires of course that this component is used by only shared systems or that the RNG rolls are the same client and server.

tom-leys commented 1 year ago

The easiest way to lag comp entities back in time is to store a short array of positions, which is updated in TransformComponent each frame. When a shot happens the server needs to know exactly the tick it is based on so it can walk the entity back in time. This gets more tricky with clientside prediction if the server and client disagree on where the target was that frame.

You almost need to walk the target back to the last network sync relevant to the client and then predict it forward. But only if we have prediction diverge between client and server (do those tend to diverge?).

I imagine that target input controls changing is going to be the main source of divergence.

metalgearsloth commented 1 year ago

You almost need to walk the target back to the last network sync relevant to the client and then predict it forward. But only if we have prediction diverge between client and server (do those tend to diverge?).

We have a lagcompsystem which is currently used for melee which you would also use here for some validation.