Connecting from Unity and passing messages

Connecting to a Photon Server from Unity is very simple. You just need to specify the IP, port, and application which you want to use (in this case, we will specify PhotonAckServer as the application). Each application defined in the Photon Server configuration will run alongside each other—this lets you run a number of different server types such as master servers and game servers on a single physical machine.

Let's create a script to connect to Photon, service the connection ten times per second, and sends a test message to the server (which responds with an acknowledgement message).

First, we'll start with this:

using UnityEngine; using System.Collections; using ExitGames.Client.Photon; public class PhotonAckClient ...

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.