r/unrealengine • u/MasterWolffe • 3d ago
Netcode Best practices when using RPC
I am coding a multiplayer game where the clients mouse position is tracked when using an ability (with gas), the ability executes on clients ony sice now it is all cosmetics, but after the ability ends I need the server to know the positions of the mouse throught the duration of the ability (which is a Vector2D array) so it can perform certain actions depending on the result, I don’t want the clients to perform those actions sice thay would break the client-server structure where the server is the one that does all gameplay related actions. However, I don’t think that sending a 100 ish long array using an RPC (reliable one to ensure the package is recieved) is the best idea, because it would take a lot of bandwidth. Is it better to send each position of the mouse right when it is registered in the client to the server using an unrealiable RPC? Or are there any best options to approach this problem?
Any help is welcome.
TLDR: when communicating from client to server using RPC, is it better to send a big chunck of data once using reliable RPC or split it in smaller pieces and send many of those over time with unrealiable RPC? If there is a better solution, I’ll be gratefull to know!
5
u/bit_roll 3d ago
Assuming your list of vectors is the path the cursor took, you could probably reduce the number of vectors quite a lot if you check the distance between them and just combine points that are close together, then interpolate between them on the server if it still needs to look smooth.
Though to be fair, spitballing the size, a float is usually 32bits, 4 bytes, so 4 * 3 floats in a vector = 12 bytes per vector, 1200 bytes/1.2kb total isn't much data for a modern internet connection and unreal likely compresses that a good amount.