I got this visual desync between projectiles on other clients, basically when the player shoots out the projectile the server fires to all clients and each client creates a visual fireball on there side but then we get the desync between clients due to normal latency problems.
i’ve tried adding a wait before the projectile comes out for latency to sync it back up to how the server may picture it but that didn’t work. I don’t really work with client - server - all client communication that often only for vfx/stationary moves.
(the way I’m moving the projectile is with physics aka. linearvelocity)
(the method I tried)
-- send being another tick being sent over when we fired to all clients
task.wait(tick()-send)
if you want an example, if two players are shooting projectils lets say fireballs at each other, the person who shot the fireball would see it hit them and it’d do damage (if the hitbox was on the client) and the person who got hit wouldn’t see the fireball hit them but still get hit.
tick is the clients time, and is often different depending on the CPU start time which is completely random per session. os.time is global and always the same for all clients and servers.
It sounds like a latency issue. Your best bet would be instead of rendering the fireball on the caster’s client first, defer the event to the server and use :FireAllClients, that way when the server receives the message, it will start the process of LinearInterping the fireball, and the clients will shortly receive the message after.
This should have the effect that the caster knows exactly when the server recognizes the fireball was created, and it’s synced up relatively well to other clients.
Edit: If you need a code example, I can provide one.
Alright, I fixed it with a few things. If anyone else has this problem I’d like to say the more you try to sync client and server the less responsive the game will feel, which is kind of obvious but I digress.
First latency, @bitsplicer you’re right about the tick event being client sided, so I used a different event.
-- (params[5] is a workspace:GetServerTimeNow() sent over to the client)
local latency: number = workspace:GetServerTimeNow()-params[5]
fireball.Position += (direction*speed*latency)
Instead of doing a task.wait() and then the latency which wasn’t really intuitive, just made the projectile go forward the amount it should of while the latency was lagging
Second problem was that things like the shooters direction was different for each person, so I made it that each client/player gets the same direction from when the player first clicks the shoot button. The only problem is the responsiveness if someone turns their camera to fast the projectile will come out at the previous direction.