4
\$\begingroup\$

I'm trying to build a real-time multiplayer game on Unity. I was thinking of using services such as PUN or UNet, but then I ran into Game Center's multiplayer API.

I've read that Apple doesn't give servers and only provides matchmaking services. Is that true? How does that work? Would I still need PUN/UNet with Game Center?

I guess what I'm trying to ask is, will Apple host my game's multiplayer instance, where position of players is synced across, and replace PUN/UNet?

Any help is appreciated. Thank you. Also, if you can provide a source with your answer, that'd be great.

\$\endgroup\$
3
\$\begingroup\$

So, its a little weird, but...

I used it once a number of years ago using Prime31's Game Center plugin. What it does is facilitate two (or more) copies of the game communicating with each other in a serverless multiplayer context.

What that means is: one of the clients is also the server (they are the "host" and act like a server for all of the connected clients).

You can do multiplayer this way and for some games it works really well (things like Space Team, Spyfall, or Codenames, where 'cheating' isn't important because the game is short and fast paced and switching to a different person as host if someone's cracked their copy is easy.

What you can't do is any thing that requires:

  • A lot of server computation (e.g. lag compensation for a first person shooter: your host won't have the system resources)
  • Any persistent data storage (e.g. any sort of RPG with stats and items, as changing hosts means restarting)
  • Lots of players (you're going to be harshly limited by the network capacity of the host)
  • Out-of-line-of-sight multiplayer (Game Center is set up to work on single-wifi-network or bluetooth connections)

In my project I was making a Tower Defense game and used Game Center to let each copy of the game that was running know about where different towers had been placed by the other people playing and give a damage, rate of fire, special effect, or range boost to towers placed in the same spot. So a poison tower placed by Player 1 would mean that Player 2's bullet tower in the same position got a small DOT effect. If Player 3 also placed a poison tower, then their tower and P1's tower would do slightly better poison, and P2's bullet tower's small poison effect would increase (the bullet tower also applied a small buff to the poison towers, but I forget what it was).

\$\endgroup\$
  • \$\begingroup\$ Thank you for the detailed answer! So from what I gather, the Game Center API works to provide a peer-to-peer architecture over local WiFi and bluetooth, but the prime31 plugin modified it to have it function over the internet as well? \$\endgroup\$ – thenash654 Oct 14 '18 at 21:13
  • \$\begingroup\$ Prim31's plugin is just an asset to get the iOS functionality from within Unity without having to write the native code integration yourself. It in no way extends the functionality. But yes, it is Peer-to-Peer networking. \$\endgroup\$ – Draco18s Oct 14 '18 at 23:35
  • \$\begingroup\$ Again, thanks for the reply! So just local WiFi and bluetooth then? Sorry, that's all I need to confirm. Game Center is pretty much useless fo me if it doesn't connect matches over the internet. \$\endgroup\$ – thenash654 Oct 15 '18 at 10:09
  • \$\begingroup\$ Add far as I know, yes, only wifi and bluetooth. \$\endgroup\$ – Draco18s Oct 15 '18 at 14:18
1
\$\begingroup\$

Draco18s is mostly correct about the no-server limitations, but in fact GameCenter does allow multiplayer across the internet. I have released at least two games that use multiplayer via GameCenter on iOS and both are successful at playing with any opponent, regardless of where they are. You simply start a multiplayer game and either choose a random opponent(s) or send an invitation to somebody via a built-in integration with the Messages app, or pick a “nearby” player from a list, as long as both devices are running the app. I’m not sure exactly how it determines what devices are nearby to put into the list, but WiFi is not even required to use it.

In any case Prime31’s plug-in is just a wrapper around the native functionality.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the reply! Could you quote a couple of games that use Game Center Multiplayer over the internet, so I can try it out? \$\endgroup\$ – thenash654 Oct 16 '18 at 17:27
  • \$\begingroup\$ PBA Bowling Challenge is one I have worked on. \$\endgroup\$ – Ed Marty Oct 16 '18 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.