I’ve implemented hitscan weapons into out multiplayer FPS following the same approach as the Generic Shooter library project. This is, simply : firing the traces clientside then RPC to server for confirmation and dealing damage. For the most part this works without any problems, however, when firing multiple traces ( IE. shotguns - we use 8 traces, which is lower than desired ) this causes lag and rubber banding consistently in our multiplayer tests. The bottleneck appears to be when sending the multiple hits to the server.
So, my question to you : Is there another approach we can take, or someway in which we can optimise the current system?
What if you instead send starting location of shotgun and direction.
Then let server do random trace and send back total damage to clients.
This way you have 2 data events per shoot instead of 2 per trace.
Yes this was our initial solution, the problem then is there can be a delay for the impacts, causing the player to have to lead their shots instead of getting the instant feedback.
Hi, today i worked on my shotgun, 20 traces without any lag.
My setup is:
Create variable vector array, on client - for loop - 20 traces - add all 20 trace values to array and then send it on server as one pack - on server foreachloop shoot all these traces, imo its hard to call server rpc 8 times in 0,001s, try my setup it works perfectly and let me know. (Dont forget to clear array on next shooting start)
If it doesnt help, post me screen of your bp and eventually ill post you mine.
I think this is something I have also tried. The problem again is that you are doing the traces on the server rather than sending the trace results to the server. This makes it much less responsive with any lag, which is not ideal for a twitch shooter ( when adding fake latency in tests I had to aim in front of targets to hit them with this method ) . Maybe this is not an issue for shotgun type weapons, but still, would like to know if there are any other ways of doing clientside based hit detection for multiple hits.
Create a random seed for your character.
Use this on both the server & client when ever you fire the shotgun.
On the client, fire the shotgun based on this seed & send the fire event to sever with a timestamp.
On the server, fire the shotgun based on same seed, but make sure to do so from the location the player was at based on the timestamp.
You may also want to keep track of all characters locations for several frames, allowing you to temporarily rewind their position to also match the timestamp.
Hey thanks for the suggestion, sounds interesting. Would it be possible for you to point me in the right direction for sending and storing timestamped locations.