Sign In Register

How can we help you today?

Start a new topic

Unity real-time multiplayer game


I'm developing a real-time multiplayer game on Unity targeting mobile platforms including WP8 and WinRT, and I would like to ask a couple of questions concerning whether GameSparks suits my project or not.

As I read here, I would be able to handle random match making according to some params but will I be able to create rooms and allow the player to invite his/her own friends as well as joining active rooms ?

Is there a documentation available for such features ?

Also, is there any tutorial for real-time objects in action? Even just moving some cubes and lerping the transform sent across the network.

Thanks a lot

Best Answer

Hi Jatin,

Yes - this functionality has been added.  If you look at the Configuration Sub-menu there is a menu item called Multiplayer.  In here you can set up both Challenges and Match Making.  There is documentation on it here:

Let us know if you need help with any of your implementation patterns.


Hi Ahmed Najeeb,

We are aiming to have room management and built in matchmaking for real-time games as official features by Q2.

Once this happens there will be detailed documentation on how to set this system up.

In the meantime, it is still possible to set-up manually via cloud code.



Thanks a lot for ur fast reply :)

Any update on this?


Hi Jatin,

Yes - this functionality has been added.  If you look at the Configuration Sub-menu there is a menu item called Multiplayer.  In here you can set up both Challenges and Match Making.  There is documentation on it here:

Let us know if you need help with any of your implementation patterns.



Finding a match is okay, but how does one send the data from one player to the other across. I understand this is doable for turn-based games, using Challenges, but how about real-time games.


Can you tell us a little more about what you are trying to do?  There are a couple of approaches for this ... Setting up a challenge where 'Turn Based' is set to off works for most things.  If you need lower level realtime performance, then please bear with us as that is in test and being used by a couple of beta customers and due for wider release shortly.

If you prefer to keep what you are doing more private, you can mail us at and we can help you with the best implementation approach.



Hi there,

Here is what I want to do:

I am making a multiplayer quiz game that is real-time.

1. Quick Match against any online player - For this i know i can use the Match functionality. Do I need to maintain the list of online players myself or is there an API call I could use to facilitate the same?

2. Once they are matched up, I need to send an array of ints or sometimes a single int to the other clients. The details being:

i. Name, Rank of the other player

ii. Question Indexes selected for this match

iii. Answer given by the other player

So now the question is how do I send this data to the other client, am I to maintain a server-side state how you did in the TicTacToe sample or is there a better way? In the former case (if I follow the TicTacToe sample) how does the cloudcode push the message to the other user? Do i have to trigger it somehow or does it just happen once the cloud-code gets run.

3. How do you handle Player Connects and Disconnects to the Match?

4. As for Player Data, I have read the blog post linked with it, but would appreciate input on what approach to use if I am just updating the same fields after each match. Player Data being:



Exp. Points:

Variables for tracking various achievements

Variables for tracking last 5 matches (for an activity log)

These values aren't updated continuously but around every minute or so (which is the amount of time it takes to play one match).

Hi Jatin,

We've taken this to email with yourselves now, but for the benefit of anyone else who reads this thread I will post much of my email to you earlier plus a small addition at the end.

Oisin from the GameSparks Support Team here.

I have some answers to your questions here to get you started:

1.Our matchmaking functionality will find online users for you without you needing to maintain your own list.

See the following documentation for more info:

2.The message system on our platform can handle sending all of those variables for you.

This could be achieved by sending a message once two players are matched.

3. With regards to disconnects, 

In the System tab in Cloud Code we have PlayerDisconnected and PlayerConnected:

Player Connected - This script is executed each time a player connects and is identified.  Spark.getPlayer()  is set to be the player who connected so you can query or manipulate the data related to the player.

Player Disconnected - This script is executed each time a player disconnects.  Spark.getPlayer()  is set to be the player who disconnected so you can query or manipulate the data related to the player.

You could store a "currentlyActiveChallenge" id on the users profile.

If they disconnect while having a currently active challenge you can then decide what behaviour comes next.

4.So here we are just storing data on the player's scriptdata.

For Example:



  "@class" : ".ChangeUserDetailsRequest",
  "displayName" : "Sorab"
}, "stringOfThePlayer who's details you want to change")




  "@class" : ".ListAchievementsRequest"}, "stringOfThePlayer who's achievements you want to see")


The last 5 matches:


 "@class": ".ListChallengeRequest",
 "entryCount": 5,
 "offset": 0,
 "shortCode": "shortCode",
 "state": "COMPLETED"
}, "stringOfThePlayer who's matches you want to see")


For attributes like rank and exp; you could store them on the player.

Skill is just a number you use to find people.

When you make a FindMatchRequest you sub in the "Rank" into your "Skill" field.


 "@class": ".FindMatchRequest",
 "matchShortCode": "searchForTicTacToe",
 "skill": 40



The request will wait the amount of seconds you set (in the match settings in the configurator) and try to find any players looking for a match within the same skill range. 

So you could store your rank and exp on the players scriptdata and then whenever you make the FindMatchRequest:


 "@class": ".FindMatchRequest",
 "matchShortCode": "searchForTicTacToe",
 "skill": Spark.getPlayer().getScriptData("rank")


And depending on how it's setup in the configurator it will find players of a similar rank.

In the above screenshot, for the first 10 seconds they will try to find someone in the 19-21 rank, for 10 seconds after that it will search within 3 ranks of the player, finally it expands the search to within 25%-50% of the player. 

Obviously you can set this up whatever way you wish, you may not need that first (Absolute) Type, for instance.

Hopefully we've given you some ideas on how to get started, for any further inquires or questions it may be best to log a support ticket here:

This will enable you to track the progress of any issues.



One more question from me?

Is any option to set number of players to match(now it is 2). I would like to have team of 4 players.

Hi Zbigniew,

You could send the FindMatchRequest 4 times, adding each new player to the challenge.



Hey There,

I am trying to implement a Real Time MultiPlayer game using GameSparks.  I am able to do the matching of two players.  But after that I am kind of stuck.  I would want to send game data like string, int and arrays from Player1 to Player2 in real time.  How can I achieve this using GameSparks?

I have seen this and it says its in Trial.  Is it still in trial is there any ways in which I can use those services?

I was working on a turn based game and I exchanged data between players by setting scriptData in the "takeTurn" event of the challenge and then wrote some cloud code when receiving the "takeTurn" challenge event to get the scriptData and set it to the challenge, thus I can access it in the ChallengeTurnTakenMessage, CallengeWonMessage, ChallengeLostMessage... Hope that helps
Login to post a comment