[UE4+Realtime+Chat] Use Photon without an in-level instance?

Options
DG Gage
DG Gage
edited June 2015 in Native
Photon Realtime and Chat are working great for me so far. So there's nothing wrong in that sense.

I based my integration off of the UE4 LoadBalancing demo, where it uses a Blueprint in the level as an instance of Photon, and in my case, both Realtime and Chat simultaneously.

I'm wanting to know how I can use Photon in more of a general capacity. What I mean is for a way to use Photon without an in-level instance. This current method makes it impossible to retain a connection while going between levels in the game.

So how I can use Photon in a way that's maybe more general, and is not based on existing within a particular level as an instance?

Comments

  • Serphimera
    Options
    I think the only way to make this persistant is to implement the logic in a custom GameInstance class. This class can also be used for storing values that must persist through map / server travels. I try to implement this myself already with a custom server logic and with PhotonPeer on the client side.
  • vadim
    Options
    Hi,
    I based my integration off of the UE4 LoadBalancing demo, where it uses a Blueprint in the level as an instance of Photon
    UE4 LoadBalancing demo is one of many possible ways of integration Photon into UE4 app. Photon SDK is completely standalone and developer decides how to create LoadBalancing client, store reference to it and exchange data between client and UE4.
    Simplest solution would be static client which available from anywhere by single reference.
  • DG Gage
    DG Gage
    edited June 2015
    Options
    vadim wrote:
    Simplest solution would be static client which available from anywhere by single reference.

    And how should I go about doing that?
  • DG Gage
    Options
    Serphimera wrote:
    I think the only way to make this persistant is to implement the logic in a custom GameInstance class. This class can also be used for storing values that must persist through map / server travels. I try to implement this myself already with a custom server logic and with PhotonPeer on the client side.

    That's a really cool idea. I suppose the Timeline elements I was using in my instanced Photon Blueprint could just be passed through a local Blueprint that can do Timelines. Plus, being able to access the game instance class that holds Photon at any time from any Blueprint is extra useful.
  • Serphimera
    Options
    Hi there,

    hopefully it will work for you. My implementation is not yet finished as I am not a very well c++ programmer :-o. What vadim said could be a another option . I think he suggests building the "client" seperately and adding a reference to ue4, perhaps as a custom lib. So the engine can communicate with your client from everywhere.

    That said I think this in combination with the GameInstance can be very helpful. Will try to implement such a client over the weekend :-)
  • DG Gage
    Options
    I can confirm that using Photon in the GameInstance class works just fine. Since you can't use Tick in GameInstance, and therefore can't call service() regularly, I placed a BP in each level called PhotonHelper, which uses its own Tick to call service() from the GameInstance. I made a function in GameInstance called U[project]GameInstance::callService that handles the call, and calling it perpetually through the PhotonHelper BPs works just fine.
  • Serphimera
    Options
    Glad to hear that you succeeded in this.
  • Serphimera
    Options
    Sorry for reviving this old thread but I finally managed to get the photon cpp api running in UE4 with a custom server in the backend. I had some issues (not with photon itself) with the engine in general as I'm not a experienced c++-programmer :wink:

    If you are interested in my implementation you find the sources on my github repository

    https://github.com/Serphimera/DragonBorn

    It's work in progress but I try to document everything deeply so that one can understand my thoughts.
  • Tobias
    Options
    @Serphimera: If you contribute a showcase or insight (like above), you are welcome to revive any old thread you like! :)

    Thank you.