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 Pipelinetemplate selected - Switch to
WebGLbuild target in theBuild Settingswindow - Under the
Settings for WebGLtab in thePlayer Settingswindow- Set
Compression FormattoDisabledfor now - Choose the
MinimalWebGL template to reduce the number of files generated
- Set
- Build to WebGL in the
Build Settingswindow
Godot
Make sure you have Godot installed.
- Create a new Godot project.
- Switch to
HTML5preset in theExportwindow - Export the project by
Export Projectbutton.
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.jsonunderunity-webgl-samplefolder - Follow the Unity WebGL sample to
- Setup the
dfx.jsonfile - Copy the files in the Unity WebGL build to the right places under the
srcfolder
- Setup the
Godot
- Create a folder named
godot-html5-sample - Create a
dfx.jsonundergodot-html5-samplefolder - Follow the Godot HTML5 sample to
- Setup the
dfx.jsonfile - Copy the files in the Godot HTML5 build to the right places under the
srcfolder
- 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