O'Reilly logo

Unity Multiplayer Games by Alan Stagner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required