I want to create a projectile system for a 2D Run and Gun multiplayer game

  1. What do I want to achieve?
    I want to implement a projectile system for a 2D multiplayer Run and Gun game that is efficient and accurate in a networked environment.
  2. What is the issue?
    Currently, my system runs on the client-side. Each player has an attribute indicating whether they are shooting, and other clients create the projectiles locally at fixed intervals based on that attribute. While it works, I’m not sure if this is the best approach in terms of performance and accuracy.
  3. What solutions have I tried?
    I have implemented the shooting system so that clients handle projectile creation based on the shooting attribute. However, I’m unsure if this is the best practice for a multiplayer game. I would like to get suggestions on how to properly handle projectile synchronization over the network.

I personally use the roblox fps template framework, but I was confused with it in the beginning so I’ll explain it here.

On the client use ray casting (or even better shapecasting) and run the effects on the client. Send the server some information like: did the ray hit an enemy, start position and end position of the ray.

On the server, if the client ray hit an enemy do some sanity checks to see if the shot can be made, if the start position is near enough to the player, you can also send the current time from the client to the server and check the current time again from the server, then compare the two to check if the time difference is too large, hence why the player is too far away from the ray start position.

In the end send the effects to the rest of the clients. You can also immediately tell the client to replicate the effects if there wasn’t a hit enemy enemy since there will be no harm done, but cheaters can just spam effects and blind other players or crash them so I don’t reccomend it

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.