I don’t know if the title is correct because i dont really know how to explain it, but im wondering how i can visualize the bullet on the client (and other clients), and on the server its an invisible ray, i heard this is better for performance. Im using fastcast and heres what i do currently:
Visualize bullet on client, send remote to server to do ray, then fireallclients on a remote and the handler visualizes it for others.
However i don’t know if its the best way so i want some help
It is a good way. There are just some aspects you should take into consideration:
Suppose we have 2 clients, A and B, and the server S.
When A fires a bullet, they will instantly visualize the bullet and send an event to S. This event takes some time to send (“T1”). When the server received the event, it fires all other clients taking a second duration “T2” after which the other clients will be able to visualize the bullet as well. This means that A sees the bullet instantly, while all other clients see the bullet after “T1 + T2” time.
It’s important because there is a desync, and if it doesn’t matter for your game that it is fair, it’s okay. The issue is that the bigger the latency/lag of A, the bigger the T1, meaning the client B will see the bullet much later.
There’s also a second option:
If you want both A and B to visualize the bullet at the same time, when A wants to fire the bullet, instead of visualizing the bullet instantly, he should rather just send the event to the S, takes T1 time, let the server do the calculations (damage, points and everything else) and then fire all clients, and after T2 both A and B visualize the bullet at the same time.
This has the advantage that A and B are more likely to be in sync and see the same information at the same time, but the issue is that A will no longer feel the bullet firing as smooth as before.
It’s all about tradeoffs, you can pick one or the other.
There’s also a much more complex way of doing this, which is ideal, and it has the positives of both methods, but it’s not something I would be able to cover in a reply on the forum.
Check out Valorant’s way of making this, it’s very interesting and it can teach you so so much about best practices in client-server replication for games: