I want to connect Node.Js, Photon PUN and Unity 3D

I love how Photon works but I have a different requirement.

I am developing a multiplayer endless runner game.

I have three requirements:

  1. Send game movements, additional info from Unity to Node
  2. Receive specific user instructions in the server node.js using external sources and send it to the unity game.
  3. Use Photon Views ( Camera Management), Photon Match Making and useful features of Photon PUN.

So, is there a way to receive a certain instruction A from the user to the server in the node.js, then send A to Photon, use Photon features (matchmaking, views etc. ) plus send A to the Unity game as well?

Node.js --> Photon---> Unity

Thanks.

Answers

  • In Photon, you always send messages from one client to other clients. You can have both Javascript and Unity clients in the same room. Javascript is always Realtime. Unity has 2 options: Realtime and PUN. Normally you have only Realtime or only PUN clients in the room (no Javascript in the latter case) but you can try to mix PUN and Realitime by ignoring PUN messages in Realtime clients.

    We've successfully run Javascript client on Node.js but do not have a guide on how to do it. In theory, Photon Javascript client can run in any Javascript environment where websockets are available.

  • Can you please share a piece of code for this? I would be really grateful. We are a startup and before going full-fledged with Photon, we need to make sure of its capabilities.

    Thanks.

    • run 'npm install ws'
    • copy Photon-Javascript_SDK.js to the app folder
    • set AppId at the beginning of app.js
    • run 'node app.js'

    Vadim