Forum General Unity scene for servers

Any issues or discussions relating to Unity development are welcome here.

Unity scene for servers

Postby dsaunder » September 27th, 2011, 7:09 pm

I just started using Unity yesterday, it looks interesting but I have some questions.

1) Is there a way to extract game object data so the server has some idea about what's in a level?
The Mushrooms example programmatically creates all the mushrooms on the server then networks them down to the client. What if I wanted to manually place a mushroom in Unity? How could I get the server to know about that mushroom?

What I would really like is a way to parse the Unity scene into something that I can embed into the server dll, any ideas?

2) Assuming 1 isn't possible, how trusted is a Unity client? How can you deal with clients becoming out of sync?

Thanks!

-D
dsaunder
 
Posts: 23
Joined: July 22nd, 2010, 7:28 am

Re: Unity scene for servers

Postby dsaunder » September 27th, 2011, 10:52 pm

After a little more research, it seems that one option with Unity is to use PlayerIO more as a back-end, leaving the client-server networking to Unity. Let PlayerIO handle lobbies, matchmaking, microtransactions, awarding experience, etc and just let one of the Unity clients act as the server. This would mimic the way TF2 does things, letting players effectively run the server, but have a secure back-end for security sensitive requests (a game-coordinator running on Steam in this case.) I'm not too keen on this approach, but it does mean using all the built in goodies in Unity...

Another option is to have a LevelSerializer script that does something like this:

Code: Select all
public class LevelSerializer: MonoBehaviour
{
   public UnityEngine.Object[] gameObjects = null;

   void Start ()
   {
      gameObjects = FindObjectsOfType(typeof(GameObject));
      foreach( UnityEngine.Object obj in gameObjects )
      {
         SerializeGameObject( obj );
      }
   }
   
   void SerializeGameObject( UnityEngine.Object obj )
   { ... }
}


Then you could run your scene, get every game object in it, then serialize it and its components to XML (or something more intelligent.) You can the embed the output in your PlayerIO server. This is kind of a nasty work flow but it's probably what I'll end up doing.

-D
dsaunder
 
Posts: 23
Joined: July 22nd, 2010, 7:28 am


Return to General



cron