This page has been translated automatically.
Unigine Basics
1. Introduction
3. Preparing 3D Models
4. Materials
5. Cameras and Lighting
6. Implementing Application Logic
7. Making Cutscenes and Recording Videos
8. Preparing Your Project for Release
9. Physics
10. Optimization Basics
11. PROJECT2: First-Person Shooter
12. PROJECT3: Third-Person Cross-Country Arcade Racing Game
13. PROJECT4: VR Application With Simple Interaction

Instancing Objects

The virtual world that you create may contain many identical objects, such as electrical supports, cars, wheels, etc. These objects should always look the same, and if you clone them, many separate copies are created. This means that if you decide to make any changes to one of the copies (for example, change geometry or some materials of an object), you will have to do it for each copy separately.

To avoid this, it is convenient to use a template and replicate its instances of it in the scene. UNIGINE has Node Reference for this purpose.

First you create and customize a hierarchy of objects with assigned materials, components, physical parameters, and so on (for example, a helicopter with numerous nodes and parts). You save this finished template to a separate file (with the *.node extension), and then add instances of this template to the scene. Each of the added instances references the template.

Creating and Exporting the Template Node
#

To create a template of a complex object, you need to follow these steps:

  1. Create the base hierarchy. Prepare the base hierarchy that will represent your object. For example, if you want to use a helicopter repeatedly in your world, assemble a hierarchy of nodes with materials, animations, logic components, and everything else that you need.

  2. Convert the node hierarchy into a Node Reference. Simply drag and drop the root node of the hierarchy to the desired folder in Asset Browser. A corresponding *.node (template) asset containing the hierarchy will be created in the folder. The node hierarchy in the world will be replaced by a reference to this asset.

  3. Place instances. The first instance in the world is the one that replaced the hierarchy when you dragged it into Asset Browser. You can add other instances by dragging the desired *.node template from Asset Browser directly to the scene or by cloning the Node Reference like any other node (Shift+Drag).

Benefits When Editing
#

When you edit any instance and save the changes, the template and all other instances are automatically updated. This approach ensures integrity when changing the parameters of reusable objects, especially if they are complex. This process looks as follows:

  1. Select any instance in the world through the Editor Viewport or World Nodes Hierarchy window. The Node Reference parameters will be displayed in the Parameters window.

  2. Click Edit. The hierarchy of the original Node Reference will be displayed in the World Nodes Hierarchy window.

  3. Edit the source Node Reference. You can make any changes: change materials, add new nodes, delete existing nodes, etc.
  4. Click Apply to save your changes or Cancel to discard them. The changes will be applied to all instances at once.

Important Notes
#

A Node Reference can contain only one root node.

Referencing the Node Reference Content from Outside
#

Node Reference should be thought of as a container for a self-sufficient hierarchy of nodes. When designing your world in UnigineEditor, avoid referencing nodes that are stored in a Node Reference directly from the outside (e.g. when creating physical joints, specifying nodes in component parameters or the target node of Player Persecutor, or when controlling nodes animation via the Tracker tool that we'll review a bit later) as such references will be lost as soon as the world is reloaded.

Transformations
#

The transformation of Node Reference is not affected by the transformation of the nodes stored in it. Thus, logic-driven and physics-driven nodes inside Node Reference will make no influence on its direct children.

In the following example, the moving grouped Node_1 and Node_2 nodes (e.g. driven by physics) contained by a Node Reference will not change the transformation of the Node Reference and, therefore, the DirectChild node will not be affected as well.

Schematic representation of Node Reference content

Schematic representation of Node Reference content

So, it is recommended to enclose all interconnected nodes in a single Node Reference to ensure logical and hierarchical integrity.

Last update: 2024-01-18
Build: ()