Skip to content

About

Photon Integration Sample

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Photon Integration Sample

Photon is a networking engine and multiplayer platform that handles all communication on its own servers. In a typical multiplayer setup, you implement the core application (gameplay) logic within your UNIGINE project, while Photon manages the networking layer.

This sample includes two Photon products:

  • Photon Realtime - real-time communication between multiple players over the network. Suitable for multiplayer shooters, racing games, and other latency-sensitive applications.
  • Photon Chat – public/private in-game chat system.

The sample includes the following functional elements:

  • Authorization Window – Simple login interface where users enter a nickname; extendable to include more advanced authentication (e.g., passwords).
  • Lobby Window – A UI to create rooms and browse the list of available rooms to join.
  • Gameplay World – The main interactive scene where objects can be manipulated in real time + chat panel.

This gives a solid foundation for for building your own UNIGINE-based multiplayer applications using Photon's networking services. From there, you can explore and integrate additional Photon products as needed.

Data Transfer via Photon

Photon doesn’t natively support UNIGINE types. To send such data over the network, it must be serialized before transmission and deserialized upon receipt. This sample provides utility code for that, including:

  1. Common data types supported by Photon - listed here under Common-cpp.
  2. More complex data types (e.g. transformation matrices) requiring explicit registration for custom serialization.

How to Run the Sample

Prerequisites

Step-by-Step Guide

To get started with the Photon C++ Sample:

  1. Clone or download the sample.

  2. Open SDK Browser and make sure you have the latest version.

  3. Add the sample project to SDK Browser:

    • Go to the My Projects tab.

    • Click Add Existing, select the .project file from the cloned folder (matching your OS - *_win_*/*_lin_*, edition, precision), and click Import Project.

      Add Project

  4. Repair the project:

    • After importing, you'll see a Repair warning - this is expected, as only essential files are stored in the Git repository. SDK Browser will restore the rest.

    Repair Project

    • Click Repair and then Configure Project.
  5. Download Photon Realtime C++ Windows SDK (v5.0.14 Build 3) from photonengine.com. If you don’t have an account, you’ll need to register first.

Photon SDKs

  1. Copy Photon SDK files:
    • From downloaded SDK’s /source, copy the following folders into your project’s source/PhotonSDK:
      • Chat-cpp
      • Common-cpp
      • LoadBalancing-cpp
      • Photon-cpp
      • PhotonVoice-cpp.

Tip

You can quickly access your project via SDK Browser by clicking the three dots next to your project's name and selecting Open Folder.

Project Folder

  1. Create App IDs in Photon Dashboard:

    • Go to the Dashboard at photonengine.com (the tab in the top right corner) and click CREATE A NEW APP.

    Photon App

    • Create two apps: Realtime Photon SDK and Chat Photon SDK.
    Realtime App Chat App
    Creating a Realtime Photon App Creating a Chat Photon App
    • Copy the generated App IDs in your sample project. The same ID is used for every instance (i.e. other participants don't need to create their own apps).

    Photon ID

  2. Add App IDs to the sample project: open data/application_params.json in your project /data folder and paste IDs:

    {
      "realtime_application_id": "YOUR_REALTIME_ID",
      "realtime_application_version": "1.0",
      "chat_application_id": "YOUR_CHAT_ID",
      "chat_application_version": "1.0"
    }
    
  3. Open the project in your IDE:

    • Launch the recommended Visual Studio 2022 (other C++ IDE with CMake support can be used as well).
    • Load the folder containing CMakeLists.txt. If everything is set up correctly, the CMakeLists.txt file will be highlighted in bold in the Solution Explorer window, indicating that the project is ready to build.

Warning

By default, the project uses single precision (float). To enable double precision, modify CMakeLists.txt:

- set(UNIGINE_DOUBLE False CACHE BOOL "Double coords")
+ set(UNIGINE_DOUBLE True CACHE BOOL "Double coords")

Make sure this setting matches the .project file you selected (e.g., *_double.project for double precision builds).

  1. Build and Run the project.

If the sample fails to run:

  • Double-check all setup steps above to ensure nothing was skipped.
  • Check that UNIGINE_DOUBLE in CMakeLists.txt matches the current build type (double/float).
  • Use the correct .project file for your SDK edition/platform.
  • Verify your SDK version is not older than the project's specified version.
  • If CMake issues occur in Visual Studio, right-click the project and select: Delete Cache and Reconfigure and then Build again.

How to Use the Sample

  1. Run the sample and enter a nickname in the authorization form → click Join Lobby.

Photon Authorization

  1. If no rooms exist, create one (Create Room).

Photon Create Lobby

  1. Other users with the same App IDs in data/application_params.json will see and can join it.

Photon Lobby

  1. Double‑click the room name to enter.

  2. In the world, control the material ball with:

    • WASD to move
    • QE to rotate
    • Left click to shoot.
  3. Use the chat panel:

    • Send global messages
    • Send private messages by typing @username.

Photon Messages

  1. As the health bar is empty, click Leave to return to Lobby.

About

Photon Integration Sample

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages