Raycasting on the server

Does raycasting on the server have server to client latency issues, similar to how projectiles do?

1 Like

Yes it does. Raycasting on the client will be faster

2 Likes

Know any way to handle damage on the server while having no latency issues?

2 Likes

There’s not really a way to, you just have to verify the clients inputs correctly

1 Like

How can I make sure the clients input is correct?

2 Likes

It depends on what you’re making, but you could try raycast verification. I don’t really know how to do it but normally I just check if the player was close enough to do damage assuming it’s a combat system and not a shooter

2 Likes

I’m talking about a guns/shooter

2 Likes

Try searching up raycasting verification for guns and see if anything comes up. I don’t know how to do it so I’m not the best person to ask

2 Likes

Here’s a post I found talking about it:

3 Likes

I believe they often do effects on the client to make it appear as if it’s instant/smooth.

Then the server does the damage.
So basically a double raycast: once on the client and once on the server. Giving the illusion your inputs are instant, when they’re actually not.

To accommodate for lag, I would have the client send the startpos of the ray (where the gun was located when we fired), then on the server check if that position isn’t too far away from what it appears to be at now on the server, and perform a raycast to detect the hit on the server.

2 Likes

This is exactly what I did for my first projectile system, but this causes problems when the client projectile hit a player and the server one didn’t, and vice-versa, that’s why I’m trying to make a new one.

3 Likes

With problems do you mean actual errors, or just the visual hit shows, but no damage is done?

The latter is arguably not a big deal as long as it doesn’t happen most of the time.

You’re right when it comes to bullets, but for rockets and grenades for example, the explosions are completely off, I prefer to have everything be accurate.