Quick Start

How to create a PhotonCloud game with Unreal Engine 4 -multiplatform and cross-play-

Download

You will need to buy and download the plugin for the demo to compile.

Get the plugin

Installation

Step One

Just copy the plugin in your plugins folder (engine or project).

Default code example:

git clone https://github.com/juaxix/photon_api_ue4_sample.git

Step Two

Get your app data from the Photon Cloud Dashboard. Then open the project in Unreal Editor 4

Check the photon config under project settings
  • Server Address (cloud or self-hosted)
  • AppID. (from the dashboard)
  • App Version
  • Auto Lobby Stats (gets info from lobby on join)
  • Auto Join Lobby (joins lobby when connected)
  • Use Alternative Ports (Instead of using 5055 to 5058, the ports start at 27000).
  • Connection Protocol.
    • TCP/IP
    • UDP
  • Region Selection Mode.
    • Default
    • Select
    • Best
  • Region name: for selection mode
  • Groups: separate the network inside the same room

Step Three

How to start using the example project as base

Code

photon_api_ue4_sample is used as the basic example of a multiplayer game. You can build your own version via Unreal Editor using the plugin from the store. This is an example of how to access the code of the plugin from a game project.

Useful Tip:

You can use the plugin from C++ code in your project.

YourProject.Build+
using System;
using UnrealBuildTool;

public class YourProject : ModuleRules
{
	public YourProject(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "PhotonCloudAPI" }); //be sure you use this lines
		PrivateIncludePathModuleNames.AddRange(new string[] { "PhotonCloudAPI" });
		PublicIncludePaths.AddRange(new string[] { "../Plugins/PhotonCloudAPI/Source/PhotonCloudAPI/Public" });
	}
}
										
C++ Game Mode example
YourGameModeBase.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "YourGameModeBase.generated.h"

/**
 * Example of Game Mode with the ability of adding the current PhotonCloudAPI Actor in the seamlessTravelActor list to remain when the level changes.
 */
UCLASS()
class ROLLINGPHOTONCLOUD_API AYourGameModeBase : public AGameModeBase
{
  GENERATED_BODY()

  AYourGameModeBase(const FObjectInitializer & ObjectInitializer);
  
  void GetSeamlessTravelActorList(bool bToTransition, TArray& ActorList) override;
};

YourGameModeBase.cpp

#include "YourGameModeBase.h"
#include "PhotonCloudAPIBPLibrary.h"
#include "PhotonCloud.h"

AYourGameModeBase::AYourGameModeBase(const FObjectInitializer & ObjectInitializer) : Super(ObjectInitializer)
{
  bUseSeamlessTravel = true;
}

//You need to add here the Photon Cloud Mediator Actor to avoid it to be destroyed on level change
void AYourGameModeBase::GetSeamlessTravelActorList(bool bToTransition, TArray& ActorList)
{
  AActor* mediator = UPhotonCloudAPIBPLibrary::GetPhotonCloud();
  if (IsValid(mediator)) ActorList.Emplace(mediator);
}

Callouts

If you need something special for your project related to this plugin contact me :).

Bug finder

Please if you find any bug in the plugin, report it in the issues page, together we will make a better API!