Just out of curiosity, does anyone here know the difference between GameCenter saying "Unable to Load" for scores on a Leaderboard and it saying "No Scores Available"?
I assume the latter simply means that no scores have been posted yet. But I can't seem to find any resource that describes the specific occurrences that would invoke the latter.
Hey there Prime31. Love your work. =)
However, I can't get the PostprocessBuildPlayer scripts to execute.. I downloaded the PostprocessBuildPlayer example project on Unity's homepage and it does not work either. I've tried it both on my Mac and my PC. Any ideas on what could be wrong?
@dokosten, you are now one of many with the postprocess issue. I think the round trip through the asset store ends up making PostprocessBuildPlayer* scripts lose their executable flag. Can you give it a check and see if that is the issue? A simple "chmod a+x PostprocessBuildPlayer*" will get it back.
@prime31, I already tried chmod with no luck. Can't get any PostprocessBuildPlayer script to work at all. :\ I posted a bug to the Unity guys.
Got the GameCenter plugin working and all.
I have a question in regards to Multiplayer section of the plugin.
Now, here is the scenario....
I have a racing game already made, but not for multiplayer.
So what are the steps that i need to take to actually make it playable over GameCenter using your plugin?
Meaning, when i get a response from the eventlistener indicating that a match has been found, i should go ahead and fire the level.
Within that level, should i have network view over the player's cars, for them to see each other ?
Please bare with me, i am sure tons of people will benefit from this if we can get it going...
@samshosho, The GameCenter Plugin will get you the connection really easily with the showMatchmakerWithMinMaxPlayers which then fires the matchmakerFoundMatch as you have found out. It is really beyond the scope of the plugin itself what you actually do with the open socket connection you have at that point. There are entire books written about developing multiplayer games and the protocol that you come up with is very much app specific.
I am not looking for details instruction as to how to create a multiplayer game,
But a general concept of what goes after finding a match.
You mentioned an open socket, so that means the GC server will start listening to data back and forth, but how is this data transferred between the connected devices? Is it through the sendmessagetoall call?
If yes, then if three players are playing a game how do I identify which is which in terms of targeting one player over the other?
If no, then am I correct if I say to use the old unity network multiplayer tutorial code, to transmit data?
I am just trying to get a hint so I can look in the right direction, and not details of how to do things, that will be left for myself to dig through.
Thanks in advance, great plugin by the way, works out of the box.
@samshosho, your 2 methods for sending data are sendMessageToAllPeers and sendMessageToPeers. The sendMessage* methods are *just like* the normal SendMessage function in Unity except they go across the network and require a GameObject as the receiver. The first will broadcast to all players and the second lets you choose precisely who receives the message. To track who is connected, you would listen to the playerConnected and playerDisconnected events which give you a playerId to identify the other devices (the same playerId that sendMessageToPeers takes).
You cannot use Unity networking across a Game Center socket. They are two totally different beasts completely one going through Apple's servers and the other through Unity's.
@miked and samshosho
I am just wrapping up my Unity Networking implementation (using NetworkView.RPC() method) I am going to make a new controller class for the GameCenter which instead of NetworkView.RPC uses the GC sendMessage* methods. Hopefully it will be straightforward since I've already re-factored everything to work over RPC calls, and it seems like the GC sendMessage*() classes are pretty much the same, with the main difference being how to specify the receiver.
Okay I understand that sendmessage is the same, but send message is delayed even within the same device, wouldn't it be even more delayed over a network?
How can you run a multiplayer game. A reliable one that is, using sendmessage?
Unless I am not getting the picture.
You need to send data constantly for a network game to be playable, how is it possible with send message?
samshosho, thanks! maybe others can share some insights too or correct if i'm wrong. But here is my take on it.
-GameCenter is for max of 4 players.
-Because it's a peer to peer network, It's inherently kind of variable and can be laggy sometimes
-Because the data sending is inherently RPC-ish, you must design your app for what data to send and not to send.
Very different than just throwing up a Network.Instantiate or NetworkView synchronize in normal Unity multiplayer networking.
-I've only played a handful of gamecenter games myself, and they were not exactly "speedy"
Very curious to see how it all works with the Prime31 plugin- I'm going to find out soon.
i will try few things on my side as well, with send message and see how it goes. I just got my iPhone updated to 4.2.1 yesterday, so i can try a multiplayer scenario with my iPad at 4.2.
Let me ask you something Mindlube,
When you said you are using Unity RPC to use sendmessage, did you actually adjust the cs files to do so?
Also, if you are making a multiplayer game, then you will need to send data every frame between the network players, i guess fixedupdate will be an ideal place to put the sendmessage ?
let us know how it goes on your side... and i will do so as well...
samshosho I'm not using Unity RPC and Gamecenter at the same time. I've got a NetManager class, then subclassed that for GameCenter multiplayer, for Unity RPC (for my users is Wifi networking) and then a 3rd subclass which is just a stub for playing locally vs. the computer.
Also I'm not sending every frame. My game is turn based so I just fire off messages when the game state changes.
OK good luck!
looks like you got your hand deep into networking ,,, class and subclass ,, hmmmm i am not that good at C# anyway!
i got all the way up to firing up the multiplayer level on both devices, once a match is found. Which is not bad so far !
i also got the message going, that sends data to both devices, which results in two cars moving, each on a device and the second car on each device corresponds to the networked device. in other terms, you are actually racing against each other. However...
When i got the message going, i started with one sendmessage, things were still fine, but i need more than one send message, since you can only send one set of strings through. Once i sent two or more sendmessages, the game almost froze!
@samshosho, you should be able to call sendMessageToAllPeers or sendMessageToPeers every frame with no issues at all. It is important to come up with a good protocol for your communications though due to the limitation of only being able to send strings. You can encode all kinds of stuff into a string specific to your game that way you only need to send once every frame or so.
Can you send float or int through the sendmessage , or does it have to be string ?
I dealt with converting the float or int to string, then back again from string to float or int.
But was wonder if there is a shortcut.
@samshosho, you are stuck with strings do to some limitations present. You can certainly encode ints/floats into a string than decode. Making an efficient protocol is a good idea for sure. Just encode the data you need into a string on the sending end and then unwrap it on the other end.
I think we both posted a reply in about the sametime!
I was thinking of doing what you just said in terms of packing everything in one string then unpacking on the other end.
I saw that you used something called minijson and it's included in your plugin.
Is that safe to use, to parse string into floats?
What call did you use to parse strings into words? I guess that's what you might have used it for?
When you talk about protocole and such, you lose me man!
My background is strictly unity scripting!
@samshosho, I would personally make my own simple protocol. You could use JSON but it is a bit heavy for multiplayer network packets. Here is a simple pseudo-code example that sends and receives a Vector2:
- // grab touch input, serialize and send it over to the other device
- string touchData = fixedTouch.x + "," + fixedTouch.y;
- sendData( "SomeGameObject", "touchMovedToLocation", touchData, false );
and here is the same object being received on the other end:
The idea is that you can send whatever you want in a simple, serialized bundle.
Speaking of which, another alternative to JSON is ServiceStack.Text 's JSV http://www.servicestack.net/mythz_blog/?p=176
It's kinda like JSON except faster and smaller. I had to rip out a few classes to remove XML dependencies. But so far it's working great for serializing Dictionary<string,string> and List<string> over RPC calls.