Oftentimes you want to add functionality to your game after it has been deployed. Godot enables this via a feature called resource packs (.pck-files).
- incremental updates/patches
- offer DLCs
- offer mod support
- no source code disclosure needed for mods
- more modular project structure
- users don’t have to replace the entire game
You have one project which can load .pck-files. This will be exported and deployed to your users. Whenever you want to add functionality later, you just deliver the updates via .pck-file to the users.
.pck-files usually contain but are not limited to:
- GDScript logic
The .pck-files can be entirely different Godot projects, which you load in at runtime.
In order to pack all resources of a project into a .pck-file open the project and go to Project/Export and click on “Export PCK/Zip”. Also make sure to have an export template selected while doing so.
Opening .pck-files at runtime
To import a .pck-file a one-liner is needed. Keep in mind, there is no error or exception if the import fails, so you might have to create some more validation code. The following example expects a “mod.pck” file in the directory of the games executable. The .pck-file contains a “modScene.tscn” testscene in its root.
Warning: If you import a file with the same name as one you already have in your project, it will be replaced by the imported one.
This post should show you how easy adding mods, patches or DLC to your game is. You might have to take care how you structure your project and patches as to not override anything but other than that it’s made pretty easy for us. Good luck implementing this, I can’t wait to play your game with mod support.
Thank you for reading!
Photo by energepic.com from Pexels
This post was created using:
- Godot 3.0.5
- Gimp 2.10
- Linux / Ubuntu