Finding friends

Let's say your game features a friends list, and you want to know if a friend is online or offline, or perhaps even want to join your friend if they are playing in a room. Luckily Photon Cloud recently added easy support for this via the FindFriends feature, which allows you to query the online states of a given list of users, as well the rooms the users are currently in, if any. The following example will locate and display a list of friends as defined in the inspector (in a real use case, these would likely be fetched from a database or some other source):

using UnityEngine; using System.Collections; public class Example_FindFriends : MonoBehaviour { public string[] Friends = new string[ 0 ]; void OnJoinedLobby() { // Set our ...

Get Unity Multiplayer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.