Removing projectile delay from client to server?

I have a system for an fps where a projectile is first shown on the client so there doesn’t appear to be any lag between clicking and shooting. The client then fires the server however there is a small delay between the client sending and the server being told. The server needs to do the calculation of the shot with the removal of the delay, however I realise there’s no easy way to actually calculate the delay between server and client without creating a synced value between server and client. Using the time taken between server and client the server would calculate all the ray casts that would have happened between when the client fired the server and when the server was notified then continue to calculate it as normal. I don’t know how I would go about calculating the time between the client and server as tick() is timezone relative and time() are different on both client and server. The server calculation is invisible and notifies all other clients of the shot as well.

1 Like

You can use HTTP Service to retrieve the time from a server, it would stay constant. Don’t know if there are other methods.

1 Like

You can probably have the server send the time to client and make the client calculate the offset. If I was you, I’d use time() for this as server will always join the game before the client.

--// Getting offset
local serverTime = GetServerTime() -- Invoke the server here
local clientTime = time()
local timeOffset = serverTime - clientTime
--// Firing event with time
local currentTime = time()
local serverCurrentTime = clientTime + timeOffset
FireServer(...)
2 Likes

Would you have to sync every so often to account for change in ping?

i used this for projectiles. this removes the replication lag for the client and gives damage server side but everything visually done is by client. read the post and try to see if you understand it

2 Likes

No, I don’t think you would as the counter is going on client-sided.