Jump

MIT
by MaurGi

Just Unity Multiplayer with Photon

( Crawled an hour ago )
+

JUMP (Just Unity Multiplayer with Photon)

NEW: Version 0.3 - now with offline play with bots support!

JUMP is a library that facilitates writing simple multiplayer games using Unity 3D and Photon Unity Networking.

I was working on a multiplayer game and found myself in trouble trying to handle events from Unity and Photon at the same time; ending up with fragile code - so I worked to streamline and simplify the scenario and build a reusable library.

Out of the box, JUMP Provides:

  • A simple flow for connecting to the server, matchmaking and starting a multiplayer game
  • Authoritative local Server (using Photon Master Client)
  • Streamlined Client-Server communication
  • Custom Client Commands and Server Snapshots
  • Sample Project and Prefabs to get started in 5 minutes
  • Full source code access and great customization.

Current Version

[0.3.0] - 2016-11-13 - Adding offline bots support!

For details, see Changelog

Table of Content

Table of Content

How to Install

You can get the source code here or download JUMP from the Unity Asset Store.

Prerequisites

JUMP works with Unity 5 and requires Photon PUN to function properly:

  1. Install Photon PUN Free or Photon PUN+
  2. Configure your Photon Application ID - see Initial Setup

For more information about configuring PUN, see PUN Setup.

Note: JUMP was tested with Unity version 5.3.4 and Photon PUN Free version 1.67

Option 1: Unity Asset Store

The Unity Asset Store package includes the DiceRoller sample project.

  • Download JUMP from the Unity Asset Store.
  • Add all the scenes in the DiceRollerSample/ to the Unity build
  • Open the DiceRollerConnection scene and start Unity.
  • The DiceRoller sample should go to the Matchmake scene in connected mode.

Note: To test multiplayer games in Unity, you will need to run two copies of the game, so that they can connect to each other. The best way, is to build a copy of the game (File/Build & Run) for one player and start Unity debugging for the second player. See this Unity forum post for more details.

Option 2: From GitHub source code

In alternative to use the Asset store, you can create a folder in the unity project (under Assets) and copy all the files from the JUMP Multiplayer\ folder. Then you can use the Object Model and the prefabs.

Scenario

The scenario supported by JUMP is very simple and designed with mobile multiplayer games in mind:

Two Players networking

JUMP automates building Photon game rooms, easy.

Note: While it supports more than two players, we tested JUMP with the two players scenario

Basic Matchmaking

JUMP uses Photon Random Matchmaking without the use of the Photon Lobby making the UI and the object model much simpler to use compared to the use of the Lobby.

Streamlined UI flow

JUMP supports up to five different Unity scenes:

  • Connection
  • Home Page (Master)
  • [Room] Waiting for players
  • [Room] Playing the game

Note: support for multiple levels can be added to the Playing the game scene.

Custom Server

JUMP cannot provide a dedicated remote server using Photon Unity Networking or Photon Cloud, so it uses the Host model, where one of the clients also hosts the Game Server (sometimes called Local Server)

Photon provides support for this with the concept of Master Client.

Client-Server Communication

JUMP supports the concept of an Authoritative or Semi-Authoritative server using a Command/Snapshot Client-Server communication:

  • The Client sends Commands to the Server
  • The Server sends Snapshot to the Client

The model is similar to the one explained by Fast Paced Multiplayer, but we use the term Command instead of Actions and Snapshot instad of New State

The slanted lines indicate that there is lag between the client and server communication, see Fighting Latency on Call of Duty III

While it is possible to optimize the client/server communication in terms of reliability and space utilized with delta compression of snapshots and queues of commands, JUMP simply uses Photon Reliable UDP to communicate, it is a good balance of reliability and ease-of-use.

References

JUMP Multiplayer with (Semi)Authoritative Server model is based on lots of literature on multiplayer games:


Object Model

See Object Model

Offline Bots

See Offline Bots

DiceRoller Sample

See DiceRoller Sample

Testing JUMP

See Testing JUMP

Features to Add

See Features to Add

License

Unless stated otherwise all works are Copyright © 2016 Juiced Team LLC.

And licensed under the MIT License

Donate

If you want to donate, you can simply purchase the JUMP package in the Unity Asset Store.

Contribute

We are not ready to accept pull requests at the time, we are considering that for the future. If you are interested in contributing, file a bug and we will consider your request. All contributions will be voluntary and will grant no rights, compensation or license, you will retain the rights to reuse your code.

Attribution

Photon, Photon Engine, PUN: ©2016 Exit Games®

Unity 3D, Unity Engine: ©2016 Unity Technologies