Hi, browsing around in the documentation.
I was wondering if there is a standard way in unity to stream either binary or large strings between the server and the client.
I want to, for example send an entire XML document as a string, or even better a gzipped file, across. I’m sure I’ve heard mention of people sending avatars or custom textures between players. How is that done?
This could probably done including some of the standard .NET assemblies, but would that be possible if you’ve done NAT punchthrough (doesn’t that only reserve specific ports that would the already be owned by unity?)
Many questions… any answers?
Have you checked out Unity’s WWW and WWWForm classes? They make it easy to send strings and also binary data - certain types of binary (eg, image files) can be decoded automatically after the transfer.
Cool… those look like useful classes.
I’m guessing those require you to go through a web-server. I’m looking specifically at being able to stream a serialized gamestate object directly from the server to all its clients so everyone can load from a same save-game that everyone was cooperatively playing on.
This means that there might not necessarily be a dedicated web-server that has been set up to manage all the games.
Currently the way I’m doing it is that I’m triggering a gamestate save on all clients, so they already have the data available when they continue with their cooperative game, but I just wanted to play with alternatives if they are available.
You can get the byte data of images and encode that in a bitstream to send it and parse it back into a texture for example.
but for models that won’t work. either its present in the game or you will have to write a custom model loader actually (you can not load them through WWW either)
question is why you would want to sync massive amounts of datas. You need to sync the parameters to generate the specific combination present on a client for the media thats present in all clients, that should be significantly less data. And those data, I wouldn’t collect on the server to send it as one massive block to all. sync the data on a “player block” base.
The reasoning is this… I want to be able to support multiplayer games that can be resumed by all players. Now currently what I’m doing is that I’m storing the game state on all the individual player’s machines, which is probably actually fine.
But if I wanted to be absolutely 100% sure that everyone has exactly the same state it would be nice if the authorative server could just serialize and broadcast it and that each client could just receive and deserialize it.
We’re not looking at that massive a set of data… I would guess that it wouldn’t be more than for example a 64K chunk at most, which should take a few seconds even on a slow connection.
I could use the bitstream method I think, if it works for textures. In my game I’ve completely separated the game entity data from the unity implementation. So do you still use a network view to do the transmission with some kind of custom script? Is there an example of this being done somewhere?
From the unity manual you get the impression that this is a common thing to do…
Quote from Level loading: