How to fight latency? [FastCast]

I’ve been trying to make my own gun system for a few months now, I’ve had several attempts and many different approaches, and every single one suffers from latency.

Here’s my current approach:

Player clicks → Tool LocalScript InputManager receives input → a separate Tool LocalScript immediately renders the bullet for the LocalPlayer → Server recreates that raycast from that same position → The server signals all other clients to render the bullet with the same characteristics that we received all the way back from InputManager.

Here’s a scheme.

As you can see, the server recreates the shot with a delay, causing desynchronization between the immediate bullet renderer and the server. And because of that, the server cast appeared offsetted if you fired when moving. I attempted fixing that issue by offsetting the origin on the server by the player’s velocity, and it worked at first, but it was extremely unreliable when rapidly changing directions.


This is what happens if you offset the origin position with the character’s velocity to compensate for latency. It’s weird.

I also attempted using kinematic equations to also include the latency in the origin offset calculations, but I didn’t have any luck. The offset was absurdly large with a tiny latency and a high velocity.

So what should I do?

2 Likes

Im pretty sure everyone will have latency no matter how you try to fix it.You mentioned how you have tried different approaches but the best option is to pick the best approach you have found out of the other approaches to minimize heavy latency.Also,factors such as the player is internet connection and the device they are using play a role other than how you decide to optimize your game.

1 Like

Have you tried implementing multi threading.You can use parallel programming model to synchronize and desynchronize threads.

1 Like

What the chat gpt are you saying right now.

1 Like

You are indeed correct, latency will always be there, but the question is, how do the big games like arsenal or zombie attack or pf replicate bullets smoothly and nicely?

1 Like

While multithreading can help reduce CPU/GPU time, it doesn’t resolve network latency, which is my primary concern.

1 Like

This is what is meant by “it’s a balance.”

2 Likes

Hi checcerr. I don’t think any of the replies from the 3 people here are helpful. I made a video for you to see how my team deathmatch testing place looks. Mine has maps but for the testing version it is just a baseplate. It shows you how my gun system looks. It is animated. I created it from editing Roblox’s FPS System template. I suggest using Roblox’s FPS System template.

I would say they probably did the same thing I did and used Roblox’s FPS System template but created a much more complex system compared to mine.

I hope the video gives you insight into what you can achieve from editing Roblox’s FPS System template :slight_smile:

2 Likes

Due to the poor quality of the video I made… I have decided to release this testing game publicly and you can use multiple roblox experiences to test yourself the latency that Roblox’s FPS System template has. TDM Testing - Roblox

This way you don’t have to watch and endure the poor video quality to try and see how it works. I hope this helps :slightly_smiling_face:

1 Like

Hello! Thank you so much for your reply.
I have considered using Roblox’s FPS System template earlier, however, it does not satisfy my requirements.
Looking at it’s code, if I’m not mistaken, it just tweens the visual from point A (the gun barrel) to point B (where the player had clicked). The actual bullet doesn’t actually move: it’s just an instant raycast. And because it doesn’t move, it’s less realistic on high distances, implementing proper tracers is impossible, and I can’t really affect the bullet’s motion (things like constant force, e.g. gravity).
And for that, I am using FastCast. Sorry, probably should have mentioned that earlier.

Definitely not. I wouldn’t be so sure, at least, because Roblox’s FPS template is relatively new.

1 Like