Hello!
To quickly explain, my current projectile system moves projectiles using cframes and does hit detection using raycasts on each frame. The server creates a projectile that is represented by a cframe value and does hit detection, fires a remote to every client and each client creates their own version of the projectile but with the actual instance and effects etc. The projectiles are in sync with a synced clock across the client and server. This system works really well for me, as the server handles when the projectile hits a player and does damage, while the client will do all the visual effects of the hit.
The problem is player positions are not perfectly in the same place on the server as they are for each client. For example, as each client controls their own player, walking forward will be instantaneous but the server will only see this walking a little later. So if a slow moving projectile is moving towards a player, the projectiles on the client and server are synced in terms of position, but if the player moves out of the way just in time, the server wont see this movement in time. This leads to a really big problem for me as the projectile wont show as destroyed but they will still take damage. Furthermore, a client can move into a projectile from the side and see the projectile on their client get destroyed, but the server sees this movement too late as it replicates and will not register any hit detection, leading to an invisible projectile still moving forward.
Not a very quick explanation, sorry! I wanted to avoid any sort of client side detection as if I have a moving wall for example, and all my projectiles are slow moving, it would be hard to detect if that hit detection was valid on the server as if I cast a ray it will hit the wall.
But this problem with player positions not being in the same place feels worse (even for players not lagging and with really low ping its really obviously not in sync), so I want to have clients verify each projectile hit. Then I’m at another problem where the server is creating projectiles, so which client is verifying the hit? I cant have the client getting hit verify it as that’s really exploitable, and if I have other clients verify it I have the same problem; other clients are like the server in the sense that they wont see the player’s movements instantaneously.
Even after researching lag compensation it talks mostly from what I’ve read about storing positions to turn back the clock, but wouldn’t I need the server to go into the future to see where a player is going to move before their movement has even replicated? Impossible surely?
Pretty much I want to sort out this problem with player positions not being in sync. My projectiles are all equation based so it’s really easy to use a time they were created and the synced clock to have them in the correct position, and everything goes well if the player isn’t moving. But as soon as they start dodging just in time, I have this problem. Is there any solution to this?
Thank you