The Selected Data feature can be used for all kinds of custom systems.

Selected Data is used to store different things for later use.

Selected data could be anything, e.g.:

  • a game object or multiple game objects
  • a component or multiple components
  • a variable handler or multiple variable handlers (a variable handler stores all variables of an origin, e.g. global variables)
  • a combination of different things, e.g. a game object, a component and 2 variable handlers

You can keep track of different selected data by using different Data Keys to identify them.

Like variables, selected data is available in different scopes – local (schematics, formulas), global and bound to game objects (using an Object Variables component).

The data key hitObjects holds all game objects that where hit by a raycast, while the data key variables holds the global variables and object variables of 2 game objects.

Selected data isn’t saved in save games.

Data Origin

The origin of a selected datavariable defines where it’s stored and how it can be accessed. There are 3 different data origins – when dealing with selected data (e.g. changing it, checking it or using its values), you’ll always need to select the origin.

Local

Local selected data is only available in a playing schematic or calculating formula. They’re best used for short lived information, like a game object hit by a raycast that is needed in the following nodes.

A crucial mechanic is sharing local variables between schematics and formulas that are started/used by each other – this allows passing on information and doing different things depending on where they’re started from.

Schematics

Local selected data in schematics is only available as long as the schematic is playing. The selected data is gone when the schematic finished playing.

Machines and schematics that are started by a schematic can share the local selected data, i.e. the newly started machine will have the same selected data as the one it was started by, and the schematic that started the machine will also get the changes that where made in the new machine.

Furthermore, schematics share the local selected data with formulas that are used in the schematic.

Formulas

Local selected data in formulas is only available as long as the formula is calculating. The selected data is gone when the formula finished calculating.

Formulas that are used in other formulas will share the same local selected data. Also, formulas that are used in schematics will share the local selected data with the schematic. This can be used to e.g. initialize data for the formula’s calculation.

Examples

A Raycast node stores the hit game object in the local selected data hitObject.

The following Start Tagged Machine will start tagged machines on the game objects stored in hitObject.

Global

Global selected data is available everywhere and at any time – it’s persistent in the running game, i.e. it’ll be available in all machines/schematics, formulas and other parts of Makinom.

Since global selected data is persistent, you can use it to store information that needs to be remembered for longer periods of time, like marking game objects for other schematics.

Examples

Clicking (interaction machine) on game objects stores them in the global selected data marked.

Pressing an input key (interaction machine, tick machine) fires rockets on all game objects stored in marked.

Object

Object selected data is bound to game objects in your scene by an Object ID. Like global selected data, it’s available everywhere and at any time.

Since object selected data is bound to objects, it’s mostly used for storing information that is in relation to an object, like the marked targets of an enemy.

Object Variables Component

Binding object selected data to a game object is done by adding an Object Variables component to the game object. When game objects share the same Object ID in their object variable components, they’ll share the same selected data.

Optionally, the component can be set to be used in a local mode by enabling Local Variables. When used as local variables, the object selected data is only available as long as the game object exists and can’t be shared between objects. This is usually used for storing information on not unique game objects, like enemies that are used multiple times.

Schematics and Formulas

Object selected data can be accessed in schematics and formulas in two ways:

  • Game Object
    Uses an object variables component attached to the game object to get the selected data.
    If there is no component attached, the selected data can’t be used.
  • Object ID
    Uses the object ID to get the selected data.
    This doesn’t require a game object and allows using object selected data without binding them to an actual object.

Using an object ID to access the selected data makes it available whenever needed, without a game object. This mechanic can be used to store information

Examples

An enemy searches for points of interest after being spawned using a Search Objects node and stores all nearby objects tagged Target in the object selected data targets.

Another schematics running on the enemy uses the game objects stored in targets to move to the nearest game object and check it out, removing the game object from targets afterwards.

Selecting Data

Data is selected through the Selected Data nodes in schematics (Add > Value > Selected Data) and formulas (Add > Selected Data).

There are different nodes to select different kinds of data, e.g. game objects (Select Game Objects), components (Select Components) or variable handlers (Select Variable Handlers).

Using Selected Data

Selected data can be used in various other nodes in schematics and formulas.

The Selected Data variable origin in schematics and formulas allows using variable handlers that are stored in selected data, e.g. attached to stored game objects (Object Variables component) or directly stored in the data.

Additionally, game object selections in schematics can use game objects stored in selected data. Game objects can come from game objects directly, or be the game objects of components.