Unity Multiplayer RPC + iOS Game Center?


I’m currently working on a multiplayer game in Unity for iOS devices. Currently, to connect the clients to the host, you have to type in the hosts IP address, or use a master server look up.

As this is more of a research and development project, I want to be able to use Apple’s Game Center functionality. I’ve purchased Prime31’s plugins for the Game Center (plus the multiplayer plugin).

My main question is how do I actually connect the players to my game? After looking through the demo scenes and documentations, its not really clear on how I ‘Spawn’ a player into the scene. Right now, for my IP connections, I’m using RPC to initiate the players.

I was thinking that once a player is connected via GC, could I then pass the hosts IP address and then connect in the formal Unity manor? But then again, whats the point as the client is already connected to the host via GC.

Or do I just use Prime31’s ‘sendMessageToPeers’ which will then initiate an RPC of the ‘Spawn’?

I mean, once a player is connected via GC, can I then just use my standard RPC networking system that I’ve built? Or do I have to build on top of that specifically for Prime31’s GC plugin to synchronies my game?


Yes you can use GameCenter, but if you plan on doing many calls in a real-time game, I’d highly recommend Unity Networking or another solution.

Assuming you’re using Unity Networking…

Connecting requires a server to host a list of games. The one Unity provides is called MasterServer. You can use the built-in one, but don’t deploy with it. You can download your own copy of it and run it on your own server for release.

Basically someone is the game server, the other(s) are game clients. Game server registers the game to the MasterServer, telling it the ip, port, number of players, game name, etc. Game client’s can then query the MasterServer for a game of a particular type. This will return a list of servers to which they can display and pick from, or auto-find the best one.

To spawn a network-aware object, like a player, you should use Network.Instantiate. This will instantiate the object on all connected clients, and affiliate themselves with eachother using viewIDs.

I haven’t used GameCenter for multiplayer games, but it seems like the wrong way to go. If the engine provides a networking solution, I’d bet it’s better than sending native calls to/from iOS through GameCenter.

I use uLink, which if you can afford, I recommend. It works just like Unity’s networking, but adds some better viewID tracking, much better performance, and tools and settings for optimizing and debugging.

Good luck! Hope this helps!