Question about Frontend in 2-player online game using Needle Engine

How would I best proceed if I want to create a 2-player game where both players initially log in through a web frontend and are then redirected to the actual game? Would the frontend be implemented in Unity as a scene, and then the actual game scene loaded once both players are logged in? Alternatively, would the frontend be developed as standalone (plain html/css/js) and then connected to the Needle Engine? And how would one best go about the ‘connecting’ process?
In a simplified workflow, I envision the process as follows:
Player 1 visits the designated website and logs in with a password.
After logging in, they have the option to create a new game or load an existing one (let’s set aside the loading aspect for now).
If they choose to create a new game, Player 1 then waits for another player to join.
When a second player logs in, they should join Player 1’s game, and the game scene should be loaded.

Original Post on Discord

by user 313407509618622466

Hello there – we have an experimental AI bot :robot: that might be able to help you with your question. Would you like to try this out?

How it works:
Reply to the messages of the bot that end with a thread_id to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.

Help requested: please wait a moment…

Here is what I found for you :brain: Discord

To create a 2-player game with a login and game-joining system, you can have both the frontend and the game itself as part of the Needle Engine project, or you could develop a separate frontend and connect it to the Needle Engine game. Here’s an outline of each approach:

Approach 1: Unity/Web-based Frontend and Game

  1. Create a frontend scene in Unity using Needle Engine’s UI components that allows players to log in.
  2. Implement a lobby system using the SyncedRoom component for creating or joining games.
  3. Once both players are connected to the same room, use the SceneSwitcher component to load the game scene.

Approach 2: Separate Frontend and Needle Engine Game

  1. Develop a standalone frontend using HTML/CSS/JS or any web framework.
  2. Use a backend service to manage user authentication and lobby state.
  3. Once two players are ready, redirect them to the Needle Engine game page and pass the lobby information through the URL or another mechanism.
  4. In the Needle Engine game, use the SyncedRoom component to connect both players to the same game instance based on the lobby information.

Here is the code outline for the Needle Engine side of things:


Generally the advise above sounds correct, maybe a bit convoluted.

In a nutshell: you can use our networking components which have a concept called “rooms”. Rooms have IDs that you can define. If two people are in the same room they get synchronized messsages / room state.

The lobby could be as simple as an HTML input field to type in the room you want to join, or a separate page, or… really up to your needs.

For example has a “Create Room” button and then you send the URL to someone else so they can join your game – quite minimal but effective to get players into the game :slightly_smiling_face:

thanks. is there any way to inspect the castle builder in unity to get a more detailed look?

by user 313407509618622466

It’s one of our showcase projects that license holders get access to, yes - just send a mail to with your license details and GitHub name