Step-by-Step Guide to Deploying a Unity WebGL Game on Cudos Intercloud

Step-by-Step Guide to Deploying a Unity WebGL Game on Cudos Intercloud

Deploying a Unity game on Cudos Intercloud allows developers to leverage decentralized cloud infrastructure, ensuring scalability, security, and global accessibility. This comprehensive guide provides detailed steps to deploy your Unity WebGL game on Cudos Intercloud, complete with code snippets and best practices.

Prerequisites:

  • Unity Project: A completed or in-progress Unity game.

  • Cudos Account: Access to Cudos Intercloud. Sign up at Cudos Intercloud.

  • Keplr Wallet: For authentication and transactions on Cudos Intercloud.

  • SSH Key Pair: This is for secure access to your VM.

Step 1: Export Unity Game Using WebGL

Unity's WebGL build option enables your game to run in web browsers, making it suitable for deployment on cloud platforms.

  1. Open Your Unity Project: Launch Unity and open your game project.

  2. Switch to WebGL Platform:

    • Navigate to File > Build Settings.

    • In the Platform list, select WebGL and click Switch Platform.

  3. Configure Build Settings:

    • In Build Settings, click on Player Settings.

    • Adjust settings as needed, such as resolution and compression format.

  4. Build the Project:

    • In Build Settings, click Build.

    • Choose a directory to save the build files. Unity will create an index.html file along with necessary JavaScript and asset files.

Step 2: Set Up a Virtual Machine on Cudos Intercloud

Deploying your game requires a server environment.

  1. Access Cudos Intercloud:

  2. Create a Virtual Machine:

    • Click on Create VM.

    • Select an appropriate configuration:

      • Operating System: Choose a Linux distribution like Ubuntu.

      • Region: Select a region close to your target audience.

      • Resources: Allocate CPU, RAM, and storage based on your game's requirements.

    • Add your SSH public key to enable secure access.

    • Confirm and deploy the VM.

Step 3: Configure the Server Environment

After deploying the VM, set up a web server to host your Unity game.

  1. Access the VM via SSH:

    • Use an SSH client to connect:

        ssh username@vm_ip_address
      
  2. Update Package Lists:

    • Run:

        sudo apt update
      
  3. Install Nginx Web Server:

    • Execute:

        sudo apt install nginx
      
  4. Start and Enable Nginx:

    • Run:

        sudo systemctl start nginx
        sudo systemctl enable nginx
      
  5. Configure Firewall (if applicable):

    • Allow HTTP traffic:

        sudo ufw allow 'Nginx HTTP'
      

Step 4: Deploy Unity WebGL Build to the Server

  1. Transfer Build Files to VM:

    • Use scp or an SFTP client to upload the contents of your Unity WebGL build folder to the VM, typically to /var/www/html.

    • Example using scp:

        scp -r /path_to_build_folder/* username@vm_ip_address:/var/www/html/
      
  2. Set Correct Permissions:

    • Ensure Nginx can serve the files:

        sudo chown -R www-data:www-data /var/www/html
      
  3. Verify Deployment:

Step 5: Secure Your Deployment

To enhance security:

  • Enable HTTPS:

    • Obtain and install an SSL certificate using Let's Encrypt:

        sudo apt install certbot python3-certbot-nginx
        sudo certbot --nginx -d your_domain
      
  • Set Up a Domain Name:

    • Point a domain to your VM's IP address for easier access.

Conclusion

Following these steps, you've successfully deployed your Unity game on Cudos Intercloud, leveraging decentralized cloud infrastructure for optimal performance and scalability.

For more information, refer to the Cudos Documentation.