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).

Advantages

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

Idea

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

scenes

models

textures

sound

The .pck-files can be entirely different Godot projects, which you load in at runtime.

Generating .pck-files

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.

func _your_function (): ProjectSettings . load_resource_pack ( "res://mod.pck" ) # Now you can use the assets as if you had them in the project from the start var imported_scene = load ( "res://modScene.tscn" )

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.

Summary

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!

Resources

Photo by energepic.com from Pexels

This post was created using: