[Unity] Sending a serialized object to other users

0 votes

I'm using unity and I have mazes in my games that are generated by a user.
The client can take the maze object and generate terrain/etc from it.

I'm hoping someone can point me in the right direction for sending a serialized object to all users so they can generate the same terrain. Forgive me if I overlooked it someplaye in the tutorials or forum, I didn't find anything on my own.
asked Nov 11, 2014 in AppWarp by josh (16 points)

1 Answer

+1 vote
Best answer
Hi Josh,

What I have understood from your question is that you are creating a game where a player will place objects in the world and then will share that world with other players. Am I correct?

AppWarp has a sendUpdatePeers method to send binary messages. You can serialize any object and send it with this method. The maximum limit of message is 1024 bytes for sendUpdatePeers.

I would recommend you to instead of serializing objects and sharing with other players you can share actions. Suppose when a player places an object, share this action i.e. a message representing which player placed what object at which place. You can create a JSON message for this. If you want players to create the maze all at once and then share it, you can create a JSON containing list of names of all objects with position and rotation and share it with other players. Or better if you can organise all objects in the world in a grid, then you can represent the world with a 2D array with each element in the array describing the type of object. This will make messages small in size.

answered Nov 12, 2014 by Suyash Mohan (900 points)
selected Nov 12, 2014 by josh
I like the 2D array idea! I'll take your advice on that! Thanks for the help!
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com