I am making a projectile and the projectile object itself is on the client while the hit detection is done on the server. I am sending a time stamp from the server to the client to essentially find the time that has passed on the server as the client receives the event. After that I am trying to divide the time passed by the time it takes for one frame to pass in seconds, or basically getting the amount of frames that have passed since the server started detecting hits.
The reason for this is because I am using RunService.Heartbeat to move the projectile on both the server and client and I want the projectile on the client to be in sync with the server so I am spawning it at a distance that is equal to the amount of frames multiplied by the projectiles speed away from the player. The problem is that I am not sure which time measuring system to use tick or os.time or workspace:GetServerTimeNow. The other issue is that since frames are not consistent, the clients prediction is inaccurate. Here is the code I have so far :
Server :
SpawnEvent:FireAllClients( tick() , Direction , pos1 , ProjectileModule.Speed )
I don’t think you can go better than this, there will always be an inconsistency, because ping isn’t a static thing. Maybe a way is to implement predictive hitboxes, where the server mimics the player’s ping on the hitboxes of other players so that the shots seem more fair.
Well if you want the projectile to be smoother more synchronized too you could use networkownership maybe? Or you could try using coroutine/task library functions like coroutine.wrap or task.spawn so that these threads fire quickly.
I’m not too sure if this’ll help but you can try using SetNetworkOwnership. Basically this’ll allow all the physics and stuff to be controlled on a players client side.
multiply the knife position with the heartbeat’s deltaTime, how much time it takes for physics to process varies from step to step so doing this would make the speed consistent.