When the client shoots a weapon in hits perfectly, but during the time it takes for the client to send relevant information to the server, and then have it to fire the player couldve moved and so the problem. (refer to diagram if still confused)
a friend of mine has suggested to cast a ray on both the client and server, then (assuming the client has hit an object) utilize the ClosestPoint function to check if the magnitude of both rays is within acceptable levels, and then if that returns true deal damage.
However im using fastcast and im not sure if the closestpoint function is compatible as fastcast has its own ray constructor functions rather than using ray.new explicitly.
local serverCompare = (serverNew.Unit:ClosestPoint(Part.Position))
local clientCompare = (clientNew.Unit:ClosestPoint(Part.Position))
if (serverCompare - clientCompare).magnitude < 10 then
(deal damage)
Any help on this issue would be appreciated, I am willing to post code if it is needed.
No thanks, Id like to use fastcast and im not very good at programming physics stuff like fastcast has. Please comment something insightful/ answer the question next time.
On the server, keep a track of the locations of all the players at a fixed interval and the ping times of all players. When a projectile is hits a player on the client, have the client fire a remote to the server to indicate that it has happened. Then, on the server, you will need to make fake clones of all the players and interpolate the positions of them all based on the ping time of the client which fired the remote and the positions which you have been tracking. See if the ray actually hit the player by shooting one at the fake players
interpolate the positions of them all based on the ping time of the client which fired the remote and the positions which you have been tracking
Could you clarify what you mean by this? Would i take the clients ping and use that see what character appeared on their screen at the time, then checking if the ray hit said character?
like, would i have to move the character back and then do a magnitude check? how would i use the players ping to achieve this? if its magnitude how to i do that with fastcast?
The lag shown in your image seems to be a lot, I don’t use FastCast and I don’t know is your image even accurately reflecting the lag. Regardless, @/IProgramForFun is correct, make your own raycast module which you can have a better insight on how everything works. It is not necessary to be very complicated, my own raycast modules only consist of less than 500 lines. (I think)
There’s definitely a delay between client and server raycasting, instead of checking 2 different positions between client and server, I suggest that you should just compare the time taken for the remote to fired. Such as if it takes over 2 seconds for the server to receive the remote signal since the client fires it, decline the shot.
dont have the time/ experience to create my own raycast module and denying the players shot just because the servers have messed up leaves the player confused and annoyed, again these are simply not considerable options and id much rather take the time to create a lag compensation system like @UntitledProtocol suggested.
If anyone else is still having this issue, the best scenario is to fire a ray on the client, and send over the Instance and the RaycastPosition of the FastCast Ray and compare their magnitudes, if the distance between the two is less than ten, its likely that the shot should hit.
If you really want to keep exploiters away, you could also fire a ray on the server, and if the points between the client and server ray are too far then invalidate the shot.