Syncing Physics-Based Projectiles

Hey, and thanks for reading in advance.

In the class-based fighter we’re making, one class in particular needs to use projectiles that bounce and are affected by gravity - thus we turn to default Roblox physics to achieve the movement.

We allow the client to create its own projectile that is used for hit detection, and attempt to simulate this exact shot on the server for verification. However, due to natural occurrences of latency, and also a strange penchant for the physics engine to simply halt a server-owned projectile for a few frames upon instantiation, we run into a desynchronization issue (the server shot is the blue orb).

Now, realistically - we could use this under different circumstances. Shots don’t collide with players - merely terrain; but if ever we create a map that has moving parts, the time differential could cause the shots to travel in entirely different paths. Due to security concerns, we want to avoid having one single projectile created by the server that the client has network ownership of (unless we’re out of options).

Is there a simple means of getting these shots on the exact same time-schedule? Would we need to use a ballistic formula that factors in remote network latency? Any help or advice is appreciated.

3 Likes

Physics on the client and server are always going to be different. You could try custom physics, but that might be too much work for the task at hand. I would just reccomend getting a rough idea of the ball’s trajectory and using that for sanity checks.

1 Like

I’ve heard of using workspace:GetServerTimeNow() to sync the gap between client and server latency, or at least cut down on the visuals of it. I’m not entirely sure how to offer code that’ll help since I don’t know what the current code you have looks like, but this could be a place to start.

2 Likes