When i compare raycast endpoints from client and server for shooting tolerane they are different

I have a server shooting function and a client shooting function and I compare the the start points and endpoints and give an exception of 15 units But the endpoints of the two are up to 200 units apart half the time please help

You should never expect clients to be 100% accurate. There will always be some latency and you can only try to simulate the server state as good as possible.

Why do you need them to by perfectly synced? What are you trying to achieve?

In my projects, focusing on server casts works well enough (= server is authoritative in every aspect)

thank you for replying i was trying to create a way to see if client was cheating by comparing the two raycasts and seeing if they were within 15 units of each other.

also quick question is having the Server raycast deal the damage and client raycast do animations and effects eg: hole in wall.

is this enough to stop cheating

There is no real solution to stop cheating. Even AAA studios can’t solve it. For example Valorant goes as far as putting their code in your PCs kernel and there’s still hackers in the game already…

Don’t give too much effort on this topic. At some point it’s not worth the time.

Being server authoritative is enough to cover most of the problems. Latency will be an issue then but oh well, show me shooter where it’s not…

Damage should ALWAYS be done on the server anyways.

Thanks you have been a great help

The recommended approach is to use a tolerance if you must, or ideally just to not care. You can do raycasts on the client to anticipate visual effects and stuff, but leave the authoritative logic to the server, like the raycasts that inflict damage.

You can see a good example of this in the Shootergame example, which you can download from the Epic launcher under the “learn:” tab, all the way down under the games section. This is a good starting place for learning how to do a shooter.

The documentation covers a good amount of detail as well of the separation between client and server logic