Using Linked Libraries In Game

Linked Library is a Blender feature that allows referencing a datablock from another blend file into the current one, allowing easier manipulation of common assets and better project management, as you only need to edit the original file to update all the references. UPBGE supports this Blender feature, specially group instances, which ones are fairly well integrated through Python. This tutorial aims to show how to use linked libraries, group instances and manage the links.

Before We Start

To proceed with this tutorial, we need some base files first. On a directory, save three empty blend files: game.blend (which will contain the references from the libraries), lib_character.blend (which will contain the actual model of our character) and lib_scenery.blend (which will contain the actual model of our ground). We’ll edit the file game.blend later, first we must create the contents of our libraries.

lib_character.blend

Add a Monkey object, add it to a collection (M) and rename the collection to player.

lib_scenery.blend

Add a Plane, scale it up by 5 (select plane > S > 5 > Enter > size of 10x10), and add it to a collection named ground.

Both files should be set up somewhat like this:

../../../_images/08-linked_libraries.png

Split view of the two files

Linking Collections

Now, we’ll create a blend file named game.blend on the same directory as our previous files. In this file, we’ll do the following procedures:

  • Go to File > Link….

  • Select either lib_character.blend or lib_scenery.blend file.

  • Select the Collection folder.

  • Select corresponding collection and double click it/click Link.

  • Repeat linking the other collection.

../../../_images/09-linked_libraries-linking.png

Linking procedure

If everything went right, you should see in the 3D Viewport the collection instances added. They are not editable as they are only Empty objects referencing collections from the original files. The Outliner shows chain icons, signifying those collections are linked.

../../../_images/10-linked_libraries-linked.png

Collections instanced in game.blend scene

With the instances added, all you have to do is place them with the desired transformations, and if you need to edit all the placed instances, just edit the original file to update all the references. Pretty handy, isn’t it?