Download

Question about Netcode efficiency (Shotgun attack)

Hey everyone!
I’m currently thinking about two methods to do a shotgun attack in a multiplayer game and I would like to know which method is better.

Let’s say a shotgun blast fires 20 pellets towards enemies for this example. The client always does a for loop for the amount of pellets that are in the attack.

Method A)
Inside the ForLoop the client sends the result towards the server and the server checks what was hit. This means for each pellet, I send a packet to the server to do a check. My main concern here is that this may cause a very high packet amount for the net traffic. Or does UE4 handle this type of request by gathering all the requests into one packet and send this one over? Let’s imagine I increase the amount of pellets per shot to 100 or even 1000. I think this would totally kill the network traffic, right?

Because I don’t want to cause too much network traffic, here is…

Method B)
Client gathers all the hit results into 4 arrays. One for vectors where shots have missed, one for vectors where shots have landed, one for actors that have been damaged and one for the damage that is dealt for the hit actors. After that, the client sends those 4 arrays over to the server who does the effects and damage calculation. This has two major problems. First, the server has no way of preventing any kind of cheat the client may be using. Second, if an actor is already dead, but the client did not get the message yet, the clients shots are still going into the same target.

I’m currently using method B to prevent net traffic from overloading. But if the Unreal Engine already gathers packets before sending them, I might switch over to method A since it’s much safer.

What do you think?

Use one random seed generated by the client on fire. Send it across. Create all the data from that one value. Client does graphical representation. Server handle All hit logic allways and forever and sends the result to the relevent actors.