Websocket + SQL Backend
π Quickstart - WebSocket + SQL Backend
In this guide, you'll learn step-by-step how to set up the WebSocket + SQL backend for BulletHell Elemental Template v1.4. This backend option requires additional server-side configuration but offers full database support and online multiplayer functionality.
Websocket Colyseus Server - Download
SQL database file - Download
π― Unity Project Setup
Open the Login Scene:
Locate
BackendBootstrap
in the Hierarchy.In the inspector, change the Backend Selection to
WebSocket SQL
.
Configure Backend Settings:
In the
Server Url
field, input your server IP.Example for local testing with XAMPP:
ws://localhost:2567
π οΈ Server Setup (Local - XAMPP)
π₯ Installing XAMPP:
Download and install XAMPP for your OS.
Open XAMPP Control Panel.
Start Apache and MySQL services.
ποΈ Database Creation (MySQL):
Open your browser and navigate to
http://localhost/phpmyadmin
Click "New" and create a database named:
game_db
Select
game_db
, click "Import".Choose
DatabaseImport.sql
from the server folder provided with the template.Click "Go" to import the tables and initial data.
π Server Setup (Production - Colyseus)
π» Node.js and Dependencies:
Install Node.js v22 LTS.
Open Terminal or CMD.
Navigate to the provided Server directory.
Run
npm install
to install all required packages.
π Configuring .env
Files:
Create two .env
files: .env.development
and .env.production
. Modify them as follows:
Example .env.development
:
SAMPLE=development
PORT=2567
AUTH_SALT=your_generated_salt_here
JWT_SECRET=your_jwt_secret_here
SESSION_SECRET=your_session_secret_here
BACKEND_URL=http://localhost:2567
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASS=
DB_NAME=game_db
REDIS_URL=redis://127.0.0.1:6379
For production (.env.production
), replace localhost
with your server's public IP address.
π¦ Running the Server:
For development:
npm start
For production:
npm start
Your WebSocket server should now run at:
ws://localhost:2567
for localws://YOUR_SERVER_IP:2567
for production
π Exporting Game Data from Unity
Run Unity Game in Editor:
Open the
Login
scene and press Play.Ensure you are logged out to return to the Login screen.
Export JSON Data:
Select
ExportDataJson
GameObject in Hierarchy.Click "Export All Game Data" in Inspector.
Minimize Unity and maximize again (forces data refresh).
Locate Exported JSON Files:
Files are located in the Unity project's
Data
folder.Copy these files into your server's
Data
directory.
π Done! You have successfully configured the WebSocket + SQL Backend for BulletHell Elemental Template v1.4. Now you're ready to test and deploy your online BulletHell game!
Last updated