Unreal Engine

All C++ based Photon SDKs are compatible with the UNREAL ENGINE off the shelf.

In detail the multiplayer SDKs you can gear up with the UNREAL ENGINE SDK are

You get all Photon SDKs from the Download page.

Get Started

Proceed as follows to integrate any of the compatible Photon multiplayer game SDKs with the UNREAL ENGINE SDK.

  1. Download the UNREAL ENGINE SDK.

  2. Download the Photon SDK for your targeted Platform: iOS, Android (NDK), Windows, Mac OS X

  3. Only UE4 'C++' projects are supported.

  4. Unpack the Photon SDK of your choice (Windows, Android or iOS) in the 'Photon' folder inside of the 'Source' folder of your UE4 project.
    Only the header files and pre-built libraries are required. You may want to add libraries for multiple different platforms.
    Sample folders layout:

            \---Source
            +---Photon
            |    +---Common-cpp
            |    |    \---inc
            |    |        (*.h)
            |    +---LoadBalancing-cpp
            |    |    \---inc
            |    |        (*.h)
            |    |---Photon-cpp
            |    |    \---inc
            |    |        (*.h)
            |    +---lib
            |    |    +---Android 
            |    |        (*.a)
            |    |    +---iOS
            |    |        (*.a)
            |    |    \---Windows
            |    |        (*.lib)
  5. Modify the Photon headers to workaround an incompatibility with the UE4 headers.
    Rename FLOAT to EG_FLOAT, or apply Source\Photon\photon.patch from the reference project:

            Photon/Common-cpp/inc/Enums/TypeCode.h
        @@ -18,7 +18,7 @@
        -            static const nByte FLOAT              = 'f'; /**<float*/
        +            static const nByte EG_FLOAT           = 'f'; /**<float*/
        //
        Photon/Common-cpp/inc/Helpers/ConfirmAllowed.h
        @@ -76,7 +76,7 @@
        -            static const nByte typeName = TypeCode::FLOAT;
        +            static const nByte typeName = TypeCode::EG_FLOAT;
        //
        Photon/Common-cpp/inc/Helpers/ConfirmAllowedKey.h
        @@ -43,7 +43,7 @@
        -            static const nByte typeName = TypeCode::FLOAT;
        +            static const nByte typeName = TypeCode::EG_FLOAT;
  6. Modify the Photon headers to fix an RTTI detection issue that would otherwise appear when compiling with UE4:

            Photon/Common-cpp/inc/Helpers/TypeName.h
        @@ -14,7 +14,7 @@
        -#if defined _CPPRTTI || defined __GXX_RTTI || (__GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 3 || (__GNUC_MINOR__ == 3 && __GNUC_PATCHLEVEL__ < 2))))
        +#if defined _CPPRTTI || defined __GXX_RTTI
  7. Edit the "*.Build.cs" file of the UE4 project to load the libraries for a given platform and to set Photons platform defines.
    See "Source/PhotonDemoParticle/PhotonDemoParticle.Build.cs" in the demo that is linked below and UE4 documentation:

        private string PhotonPath
    {
        get { return Path.GetFullPath(Path.Combine(ModulePath, "..", "Photon")); }
    }
    //
    if ( Target.Platform == UnrealTargetPlatform.Android)
    {
        // Set _EG_WINDOWS_PLATFORM for Windows, _EG_IPHONE_PLATFORM for iOS and _EG_IMAC_PLATFORM for OS X
        Definitions.Add("_EG_ANDROID_PLATFORM");
        //
        PublicAdditionalLibraries.Add(Path.Combine(PhotonPath, "lib", "Android", "libcommon-cpp-static_debug_android_armeabi_no-rtti.a"));
        PublicAdditionalLibraries.Add(Path.Combine(PhotonPath, "lib", "Android", "libphoton-cpp-static_debug_android_armeabi_no-rtti.a"));
        PublicAdditionalLibraries.Add(Path.Combine(PhotonPath, "lib", "Android", "libloadbalancing-cpp-static_debug_android_armeabi_no-rtti.a"));
    }
  8. Include the appropriate Photon API headers in project sources with some workarounds; "source\photon-import.h" in the reference project:

  9. Use the imported Photon API in the source code of your project.

  10. Build your UE4 project for your platform of choice.

Notes

Some hints regarding UE4 iOS builds can be found at https://answers.unrealengine.com/questions/21222/steps-for-ios-build-with-unrealremotetool.html

Ready-to-run Demo

Find a ready-to-run proof of concept for download here

  • Follow steps 1 and 2 from above
  • Unzip the downloaded package
  • Follow step 4 from above
  • Open the context menu for "./PhotonDemoParticle.uproject" and choose "Generate Visual Studio project files"
  • If you have multiple different versions of unreal engine installed, choose the desired engine version and click OK
  • UE is now generating the project files. This may take a couple of seconds and UE will indicate that it has finished doing so only by letting the "Generating" message box disappear
  • Open "PhotonDemoParticle.sln" with Visual Studio
  • Choose "Win64" as solution platform
  • Choose "DebugGame_Editor" as solution configuration
  • In the solution explorer navigate to Games/PhotonDemoParticle and build that project
  • Debug or Run that VS project - this will start the UE editor with PhotonDemoParticle as loaded UE project
  • In the UE Editor "World Outliner" tab navigate to "PhotonLBClient" -> "Demo" -> "App ID"
  • Replace the content of that field with the App ID from your Dashboard on our Website
  • Press Play

 To Document Top