I was adding the finishing touches to my projectile system (previous one was made when I was new to coding), buuut I was wondering if there was any way to optimize the new system, which acts something like this:
- I create the projectile on the server with all of the parameters needed, then send this data to each client.
- I simulate the physics on every client, and the owner of the projectile sends the server hit data. Non-bouncing projectiles will not check for hit parts on clients who don’t own the projectile.
- The server does sanity checks for the enemy’s position and the time the projectile hit, then deals whatever on hit effect the projectile has. If it hits a non-player part and certain parameters are true, then the server deletes the part.
(If an AI owns the projectile it’ll just be simulated on the server)
My question: Would it be better to simulate the projectile on one client— then fire every few frames (or when the projectile bounces) to the server?
The server could relay data like currentPosition/newPosition to all clients so they wouldn’t have to do the math themself, but I’m not sure if this would really change much performance-wise. My only issue with the current system is the possibility of frame drops desyncing the projectiles positions from each client, but this is probably a more minor issue in the grand scheme of things . I’ve done a few stress tests and I don’t get frame drops, and very little lag with 30 projectiles running. Thanks in advance!