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
BackendBootstrapin the Hierarchy.In the inspector, change the Backend Selection to
WebSocket SQL.
Configure Backend Settings:
In the
Server Urlfield, 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/phpmyadminClick "New" and create a database named:
game_dbSelect
game_db, click "Import".Choose
DatabaseImport.sqlfrom 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 installto 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:6379For production (.env.production), replace localhost with your server's public IP address.
🚦 Running the Server:
For development:
npm startFor production:
npm start
Your WebSocket server should now run at:
ws://localhost:2567for localws://YOUR_SERVER_IP:2567for production
📁 Exporting Game Data from Unity
Run Unity Game in Editor:
Open the
Loginscene and press Play.Ensure you are logged out to return to the Login screen.
Export JSON Data:
Select
ExportDataJsonGameObject 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
Datafolder.Copy these files into your server's
Datadirectory.
🎉 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