Learn more about tagged machines and what you can use them for.
Tagged machines are Unity components that are added to game objects. They’re mostly used for starting game mechanics on objects through schematics, like destroying it after losing all health – on the player, this should trigger a game over, while the enemy should just be destroyed.
A tagged machine component can be added through the components menu (Makinom > Machines > Tagged Machine) or the scene wizard (Add Machine > Tagged Machine). A game object with a tagged machine is represented in the Unity scene view by this gizmo icon:
You can learn more about machine components in general and their basic settings in this how-to.
A tagged machine is started by schematics or timelines through passing on one or more tags, i.e. short identification texts.
The tags the machine can be started with are added in the machine’s settings – depending on the schematic/timelines call, either all or only one of the tags passed to the machine must match the machine’s tags.
Examples
A schematic tries to start tagged machines on a game object and uses the following tag (only one needed):
- damage
The game object has 3 tagged machines:
- tagged machine A, tags: destroy
- tagged machine B, tags: collect, item
- tagged machine C, tags: damage
Tagged machine C will be started by the schematic.
A timeline tries to start tagged machines on a game object and uses the following tags (all are needed):
- move
- fast
The game object has 2 tagged machines:
- tagged machine A, tags: move
- tagged machine B, tags: move, fast
Tagged machine B will be started by the timeline.
Using Tagged Machines
Tagged machines are useful to start different game mechanics on different game objects through the same logic. Using a tag to start machines on different game objects allows using other schematics or timelines for the same tag.
E.g. the death tag can cause a barrel to explode with an explosion particle effect, an enemy to fall dead to the floor and vanish, and the player to display a game over message and restarting the level.
Examples
A projectile with a collision machine tries to start tagged machines on the game object it hit using the tag hit.
The projectile hits different objects:
- player
The player’s object int variable health is reduced by the local int variable damage of the projectile’s machine (by sharing local variables with the tagged machine). - barrel
The barrel is destroyed with an explosion particle effect and an explosion audio clip. - wall
Nothing happens.
A schematic reduces the object int variable health of a game object – if health falls to 0 or below, the schematic tries to start tagged machines on the game object using the tag death.
The schematic is used on different objects:
- player
The player’s death is animated, a game over HUD is displayed and the level is reloaded after 10 seconds. - enemy A
The enemy’s death is animated and the player’s score is increased by the enemy’s object int variable points. - enemy B
The enemy’s death is animated by an explosion that also damages everything in a range of 10 world units, and the player’s score is increased by the enemy’s object int variable points.