FPS Server/Client Bullets Not Quite Right
So i've made a little setup for an FPS game, but the client-side and server-side bullets almost never seem to be in the right place. The server's bullet is always a little behind the client's bullet even when running on a local dedicated server.
Just curious if i'm doing something wrong or not, because if someone has a ping or like 4(which is what i'm getting on a local dedicated server) there shouldn't really be a difference.
Here's the basic blueprint for shooting. Client shoots and +Fire is called on the server and they both execute the same code that does a line-trace using the controller's rotation and the camera's position and hits something. Very simple and straight forward code. But this is the result while strafing. Am i missing something is the server's +fire supposed to have some sort of delay based on something? This also gets really bad if you flick and shoot, both the server and client are running at 90fps/ticks so... i'm kinda stumped and i don't want to do something like send location and rotation of the shot with every bullet fired, because that seems like a massive waste of bandwidth, not to mention the cheating possibilities.
Red: server Blue: Client Strafing Right So the server's event gets called early or something, or the player's position on the server is not in-line with the client which on a local server really shouldn't be the case.
So I ended up doing this: Basically every time the client files a projectile, it tells the server and it does it on it's end also and does some very basic checks to legitimize the shot, before multicasting it to everyone else. let me know if there's a better way to do this. Because sending info on every shot from the client seems a little wasteful to me, but maybe that's the way it has to be, in order to get accurate shots.
answered Mar 12 '17 at 01:08 AM
I use server authoritive hit detection. on the client when the player fires a bullet weapon, i run the muzzle flash, recoil, sound fire effects and then tell the server that the local player started firing as well as a timestamp (that is a replicated float sent from server to client) of when the player started. This timestamp is compared with the timestamp on the server to see how far behind the client staryed firing. On the server, I have a trail of capsule component which follow the character which pick up the delay and validate clients actual hit. So i dont have to replay events backward.
answered Aug 23 '17 at 05:27 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here