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.
Open Your Unity Project: Launch Unity and open your game project.
Switch to WebGL Platform:
Navigate to
File
>Build Settings
.In the Platform list, select
WebGL
and clickSwitch Platform
.
Configure Build Settings:
In
Build Settings
, click onPlayer Settings
.Adjust settings as needed, such as resolution and compression format.
Build the Project:
In
Build Settings
, clickBuild
.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.
Access Cudos Intercloud:
- Visit Cudos Intercloud and log in using your Keplr wallet.
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.
Access the VM via SSH:
Use an SSH client to connect:
ssh username@vm_ip_address
Update Package Lists:
Run:
sudo apt update
Install Nginx Web Server:
Execute:
sudo apt install nginx
Start and Enable Nginx:
Run:
sudo systemctl start nginx sudo systemctl enable nginx
Configure Firewall (if applicable):
Allow HTTP traffic:
sudo ufw allow 'Nginx HTTP'
Step 4: Deploy Unity WebGL Build to the Server
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/
Set Correct Permissions:
Ensure Nginx can serve the files:
sudo chown -R www-data:www-data /var/www/html
Verify Deployment:
- In a web browser, navigate to
http://vm_ip_address
. Your Unity game should load and be playable.
- In a web browser, navigate to
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.