how to use Unity as part of server application?

NimbleSprite
edited December 2019 in Photon Server
Thx kindly for all help or pointers in the right direction! My friend and I have not found this topic to be well-covered online. We have seen setups for dedicated servers where Unity is used as a simulation of a game (server-side) for use with a deterministic lock-step engine. We see these setups using 2 separate Unity projects, one which is on the server and serves as the simulation of course and one which is the client layer, but we are not sure how to run/communicate with a unity project as part of the server application, as opposed to just running some C# code. So, how to make use of Unity on the server side as a separate project from the client-side Unity project?

Comments

  • Hi, @NimbleSprite

    This topic is not well covered because we do not have anything to communicate with headless unity. Fist of all this approach is quite difficult to scale. UnityEngine is quite heavy.

    I saw that other developers use plugins and communicate with unity using GRPC. I do not have any details to share with you.

    best,
    Ilya
  • From the photon server doc - 'You can actually run Unity instances on the server. Your Photon Server logic will be written in C#, so it's easy to start one Unity process per Room and communicate with it as if it was another client. Locally, it doesn't add lag. However, you need the CPU, engine licenses and automated workflow to start, stop and cache Unity instances. One per room and scene and you need to keep scenes on the server in sync with those in clients.'

    It is easy to start one Unity process per room? How so? Maybe there is a misunderstanding here
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @NimbleSprite,

    I assume starting Unity instances on the server is not something specific to Photon.
    Others like spatialOS are doing this.

    By easy, I think we mean, starting Unity process with arguments like from command line.
    As the documentation states, you need a lot of resources to run a Unity process per room & you need the license(s) necessary.
    Also not sure how the Photon server/plugin could communicate with the Unity process.

    Another approach for this is to use the Unity DLLs from the Photon server/plugin.

    Did you consider Photon Bolt for this?
    It's maybe more suitable for the Headless Server.

    Thanks for pointing out the documentation.
    Maybe we should update to clarify.
  • NimbleSprite
    edited December 2019
    Thanks again for continued help. I am trying to make a 1v1 deterministic RTS game. I wanted to use headless unity to do simple yet sensitive physics server-side, and I now see that is not so easy or practical. My best idea currently is to use the Photon Server v4 as a proxy between clients (routed peer-to-peer) and use lock-step, using algorithms on the server to prevent hacking. My whole aim is security and determinism. I don't see how I am supposed to use Bolt as a headless server and fill these requirements. Bolt is not inherently deterministic, even though it sync's desired client states, is it? Is there a way to use Bolt as a headless server and achieve determinism?