- Home /
Unity High Level Api Random Disconnect
I'm making a multiplayer game and we get randomly disconnected after a while. I think its because of the 4608B/s limit but I'm not sure.
My current usage is this:
I call a ClientRpc 15 times per second on the server, which sends it to N clients.
The parameter for the Rpc is an array of structs. The struct as the following properties:
struct update {
public GameObject target;
public Vector3 position;
public DeltaVector3 rotation;
}
A DeltaVector3 is again a struct that looks like this:
public struct DeltaVector3 {
public sbyte x;
public sbyte y;
public sbyte z;
}
Given this information, that ClientRpc should use per second:
N x (SIZE_UPDATESTRUCT + HeaderOverhead) x 15 Bytes per second
To calculate the size of the update struct I'm using:
DeltaVector3 is 3 bytes. A vector3 contains 3 floats so should be about 12 bytes. I don't know how much the hash for a gameobject is, but I'll randomly guess its 4 bytes.
That means the size would be 3 + 12 + 4 = 19. The maximum ip header is apparently 60 bytes, so we'll calculate worst case. That brings this rcp to N x 79 x 15 = 1185N bytes.
Then we also need to bring the deltas from the client to the server so each client sends a command 15 times per second which has a Vector3 delta and a DeltaVector3 rotation as parameters. So that should give N x (60 + 12 + 3) x 15 = 1125N Bytes
So our total usage would be 2310N bytes, divided by N clients gives 23100 bytes. This should be well within the 4608 bytes we get each second.
I'm using a few more commands and rpcs but they rarely get called and with rather little data.
Am I making a mistake in my logic?