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

  1. Open the Login Scene:

    • Locate BackendBootstrap in the Hierarchy.

    • In the inspector, change the Backend Selection to WebSocket SQL.

  2. 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 local

  • ws://YOUR_SERVER_IP:2567 for production


πŸ“ Exporting Game Data from Unity

  1. Run Unity Game in Editor:

    • Open the Login scene and press Play.

    • Ensure you are logged out to return to the Login screen.

  2. Export JSON Data:

    • Select ExportDataJson GameObject in Hierarchy.

    • Click "Export All Game Data" in Inspector.

    • Minimize Unity and maximize again (forces data refresh).

  3. 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