Best Way To Render Projectiles Without Lag?

Hi,

I’m a new poster. Curious how I should be rendering projectiles?

I’m currently using the method below:

  1. Player clicks tool > fires server
  2. Server spawns a new projectile
  3. Projectile eventually adds to debris

A couple things to note:
-The projectile uses a VectorForce
-The weapon’s Ray-casting is done on the client, the server recalculates this on the server to verify this

But still the projectiles lag the second they’re created and are stuck mid-air for
1/2 a second after they’re parented to workspace, then minimal lag afterwards

Ive tried :SetNetworkOwner() and it doesn’t make a difference, it seems to lag as soon as the projectiles spawn.

Is there a better method? Or is this purely a physics engine problem?

you should only be handling the visual projectile on the client, not the server, also recalculating the raycast on the server probably adds to existing lag. I don’t believe is a necessary step anyway, simple sanity checks are fine (also see about adding a distance restriction on how far you can shoot and damage others)

How exactly does one synchronise the client visuals with the path? If the projectiles are based on Roblox physics? I.E. if a player lags slightly wouldn’t that mean they can die from an invisible bullet?

Well there’s really no way to perfectly synchronize it.

All you have to do is:

  1. Create projectile on client who shot
  2. Fire message to server
  3. Make server verify shot
  4. Server then sends message to all clients to create projectile
  5. Other clients create projectile

Of course, some people will die to “invisible” bullets, but its no different to that player dying in the same scenario but instead of it being an invisible bullet, its them walking around a corner but lagging behind on the server, causing them to die.

Lag is just a problem, there’s nothing you can do to “fix” it.

Yeah, there’s no real way to get these projectiles to be perfect. It’s a trade-off either way. Either you keep your physics based projectiles server-sided, which means you have the slight stuttering, but clients get accurate information on where the projectile is, or you make the projectile on the client, which eliminates the lag but might not be accurate to the real position of the projectile.

If your projectile really utilizes physics, think of a part with a force applied that cancels out gravity that can bounce of walls, it might be best to keep the projectile on the server.
If your projectile moves in a straight line at a constant speed, you could use non-physics based solutions, so the projectile can’t be too far off. In this case you would tell the client to create the visual projectile and move it.

Thanks it took 2 days to work out, since its now physics based rendered on all clients it looks x10 better. The arc calculation was hard to achieve, but now I can do hit detection on the server with mathy stuff. Tested side by side in a 2 player simulation and its perfectly lined up.

Here’s how it looks:

External Media