Hosting a web game on the Internet Computer
This sample project demonstrates how to deploy a web game on the Internet Computer through Unity and Godot game engines. The sample DFX projects are available at the examples repository.
Before you begin, make sure you have DFX SDK installed.
Create a Web Game
Let’s create a web game by using Unity or Godot game engine.
Unity
Make sure you have Unity installed.
- Create a new Unity Project with
Universal Render Pipeline
template selected - Switch to
WebGL
build target in theBuild Settings
window - Under the
Settings for WebGL
tab in thePlayer Settings
window- Set
Compression Format
toDisabled
for now - Choose the
Minimal
WebGL template to reduce the number of files generated
- Set
- Build to WebGL in the
Build Settings
window
Godot
Make sure you have Godot installed.
- Create a new Godot project.
- Switch to
HTML5
preset in theExport
window - Export the project by
Export Project
button.
Create a DFX project
Since there is no backend in this sample, there is not any benefit of using the dfx new project_name
command to set up a template. The dfx.json
file is all that is needed.
Unity
- Create a folder named
unity-webgl-sample
- Create a
dfx.json
underunity-webgl-sample
folder - Follow the Unity WebGL sample to
- Setup the
dfx.json
file - Copy the files in the Unity WebGL build to the right places under the
src
folder
- Setup the
Godot
- Create a folder named
godot-html5-sample
- Create a
dfx.json
undergodot-html5-sample
folder - Follow the Godot HTML5 sample to
- Setup the
dfx.json
file - Copy the files in the Godot HTML5 build to the right places under the
src
folder
- Setup the
You may find generating the DFX project manuanlly is tedious and error-prone, we provide a tool named ic-gamekit to help you on this. The tool is still in development, let us know if you have any feedback.
Deployment
The local network is started by running this command from the root of the DFX project:
$ dfx start --background
When the local network is up and running, run this command to deploy the canisters:
$ dfx deploy