Posted this on answers a day ago but still haven’t gotten any help
I’m syncing players with this code:
function OnSerializeNetworkView(stream : BitStream, info : NetworkMessageInfo) {
if (stream.isWriting) {
if(localLastPos != transform.localPosition) {
// ^^ only send if the player moves, using unreliable
newPos = transform.localPosition;
y = transform.localRotation.eulerAngles.y;
stream.Serialize(newPos);
stream.Serialize(y);
}
} else {
oldPos = newPos;
stream.Serialize(newPos);
stream.Serialize(y);
transform.localPosition = newPos;
transform.localRotation.eulerAngles.y = y;
}
localLastPos = transform.localPosition;
}
This works well, a player moving only sends out about 280 bytes a second. The issue is that when another player moves, you upload 280 bytes. Instead you should be downloading those 280 bytes because you’re receiving, right?
Keep note this is not authoritative
To make it a bit more clear:
Player A moves
On player A’s client: uploads: 280 bytes, downloads: 70 bytes (I assume this is confirmation of arrival? But I’m using unreliable should this be here?)
Player B’s client when A is moving: uploads 280 bytes, downloads 280 bytes. The downloading in this case is correct, its being told where the new player is. But the uploading…?
When no players move: 0 sent and 0 received
Why would this happen? Why would a client need to send info when another player is moving?
There are no bugs with the players moving on screen, everything is synced and working well. I’m using unreliable state sync and it is observing a script with the code pasted above.
And this was a reply I posted to “Have you tried using reliable and no sync and seen the difference in bytes?”
If I use no sync I can only use RPC’s I thought? I didn’t want to use reliable because I figured itd be sending bytes to confirm delivery, but since this is fast paced I don’t really need that.
I just tested and see no difference in unreliable and reliable. With two players connected when one player moves it makes the other player upload 90-120 bytes. With three players it goes up to sending ~280 bytes when another player moves.
What is also weird is the Unity stats window doesn’t add “Player 1” until the 3rd player connects (first player server, second client, third client) I am hosting the server in the editor