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

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

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