- Home /
Send array of custom class through RPC
I have an array of players for my game that contains a custom class Player. It has 2 members, one int and one string. I'm currently synchronizing them between users by putting the members into comma separated strings, splitting them on the receiving end, and re-initializing the array. However, I'd like to add a NetworkPlayer to the class. Continuing with this method of synchronizing it would most likely get too complicated. Is there any way I can send the entire array through an RPC without losing the type? I'm using UnityScript.
Answer by gardian06 · Jul 24, 2013 at 09:40 PM
RPC only supports a limits set of data types to be sent across the wire and arrays are not included. why not just turn the array into a single string using escape characters, or simplify the data you are attempting to synchronize.
are you sure RPC's dont work with arrays? because i was testing that the other day and i managed to send an RPC between local server and client, it was an array of 1,000,000 values as a test and it worked fine, i knew it worked because on the other end, i made it debug one of the values into console, im pretty sure they work anyway.
They support param lists ("arrays"), but not custom classes. So they don't support arrays of custom classes (converting the custom class to a string or other basic type is the way to transfer it)
Your answer
