Machine Components Overview

Machines are what drives your game – learn the basics about those components!

A machine is a Unity component that plays a Schematic – in short, a schematic is a blueprint for what you want to do, and a machine makes it happen. You can learn more about schematics in this how-to.

There are different machine components available for different use cases. Each machine component has it’s own documentation with more details, so let’s just get a brief overview.

  • Animation Machines
    Started by animation callback functions, e.g. when the internal IK of an animator is updated.
    You can learn more about animation machines here.
  • Animation State Machines
    Started by Mecanim animator controller state changes (StateMachineBehaviour), e.g. when entering a state or state machine. This machine component is only available for animator controller states and not for game objects.
    You can learn more about animation state machines here.
  • Application Machines
    Started by application callback functions, e.g. when losing focus or pausing the game.
    You can learn more about application machines here.
  • Auto Machines
    Started by creation or destruction of game objects, e.g. when a game object is instantiated, enabled or disabled.
    You can learn more about auto machines here.
  • Collision Machines
    Started by game objects colliding with the machine, e.g. when a game object starts or stops colliding with the machine.
    You can learn more about collision machines here.
  • Interaction Machines
    Started by player interaction, e.g. when clicking on the machine by mouse/touch or the pressing the Interact Key (while the machine is in the player’s Interaction Controller or the selected object).
    You can learn more about interaction machines here.
  • Render Machines
    Started by renderer and camera callback functions, e.g. when the machine becomes visible or invisible.
    You can learn more about render machines here.
  • Tagged Machines
    Started by schematics via tags, e.g. a schematic can start all machine tagged ‘explode’ in the scene.
    You can learn more about tagged machines here.
  • Template Machines
    Adds a machine component based on a template setting.
    You can learn more about template machines here.
  • Tick Machines
    Started by update functions, e.g. every frame (Update) or fixed framerate frame (FixedUpdate, used for physics handling).
    You can learn more about tick machines here.
  • Trigger Machines
    Started by game objects in the machine’s trigger, e.g. when a game object enters or leaves the trigger.
    You can learn more about trigger machines here.

Beside machine components, there are Global Machines that can be used everywhere and anytime. You can learn more about global machines here.

Machine Execution #

The machine component’s Machine Execution Settings defines the schematic the machine will use. Starting a schematic requires a schematic asset.

Additional settings further specify the machine’s execution, which influence the impact/effect of the schematic’s execution individually and in context to other machines.

Execution Type #

The machine’s Execution Type defines how a machine is executed:

  • Single
    The machine can be executed once at the same time.
    I.e. it can’t be executed again while it’s already running.
  • Multi
    The machine can be executed multiple times at the same time.
    Each execution will run it’s own, separate instance of the schematic.
  • Blocking
    The machine can be executed once at the same time.
    Other Blocking machines can’t be executed while the machine is running and the machine can’t start while another Blocking machine is running.
    In short, only one Blocking machine can run at a time.

Update Type #

The Update Type defines in which Unity update function the machine will be updated:

  • Update
    Each frame.
    This is the default update function and should be used in most cases.
  • Late Update
    Each frame after Update has been used by all components (and other machines).
    Best used for camera related things, e.g. when adjusting the camera to the player’s position.
    This is due to the fact that Late Update is executed after Update, i.e. when the player has already been positioned for the frame.
  • Fixed Update
    Each fixed framerate frame.
    Best used for physics related things, e.g. when dealing with rigidbodies.

Priority #

You can optionally prioritize a machine, this will update a machine before other machines. When multiple machines are prioritized, they’re order descending by their Priority number, i.e. the machine with the highest priority number will be updated first.

However, prioritized machines will start playing the schematic in the next frame, not in the frame they’re started (as not prioritized machines do). This is due to waiting for all prioritized machines that are started in a frame and ordering them according to their Priority number. I.e. a priority machine ensures starting before other priority machines with a lower priority.

E.g. 3 auto machines start when a scene is loaded:

  • machine A, no priority
  • machine B, priority 0
  • machine C, priority 5

The machines will start playing the schematics in the following order:

  • machine A
  • machine C
  • machine B

Other Settings #

There are additional settings that can be left alone in most cases.

Machine Type #

The machine type is mainly used by Interaction type HUDs to e.g. show different HUDs for different machine types.

Machine types are created in Base/Control > Machine Types in the Makinom editor.

Stop On Destroy #

If enabled, the machine’s schematic will be stopped when the machine’s game object is destroyed.

Machine End Action #

This setting handles what will happen with the machine’s game object after the machine finished executing the schematic.

Beside doing nothing, you can disable or destroy the game object.

Wait Time Settings #

You can optionally use wait times before starting the schematic’s execution and before ending the machine’s execution state.

Object Turn Settings #

You can optionally have the player face the machine and the machine face the player.

Auto Stop Machine #

You can optionally automatically stop the schematic’s execution when the machine’s conditions are no longer valid.

Input ID #

The machine can optionally use a defined input ID instead of the game’s current input ID.

Input IDs are used by input keys to allow different input origins, e.g. for local multiplayer controls or control styles.

Actors #

Game Object type actors added to the machine’s schematic can be selected in the machine’s settings. That’s the way to go in case you want to use a specific game object in your scene.

The Actors settings are only displayed if a Game Object type actor has been added to the schematic.

Resource Overrides #

Assets added to the machine’s schematic can be overridden by the machine. This further increases the reusability of schematics, as you can create more generic schematics that perform a task, but use different assets on different occasions.

The Resource Override settings are only displayed if resources like prefabs, audio clips or sprites are added to the schematic in it’s Settings node.

Example #

Overriding the prefab resource in a Tagged Machine used to animate the death of enemies allows having particle effects, e.g. a plant enemy spawning leafs while a human enemy spawns blood.

Condition Settings #

If a machine is started is depending on the selected start type (there are different start types available in the different machine components, e.g. a trigger machine can start upon Trigger EnterTrigger Stay and Trigger Exit) and optional conditions that will be checked. While some machine components have additional conditions that can be checked, the following conditions are available for most machines.

After adding conditions you’ll have the Auto Check setting available, which defines when the conditions are checked.

Orientation #

A machine can be started depending on the position of the machine and the starting object. You can check if the starting object is in front, back, left or right of the machine. E.g. you can make an interaction machine (e.g. opening a door) only able to start when the player is in front of the door.

This condition is not available for animation state machines.

Game State #

Starting a machine can depend for the game to be in defined states. The game can have multiple active game states at the same time – states can be changed automatically upon certain events (e.g. blocking the player control) and through schematics. You can learn more about game states here.

Example #

An interaction machine (e.g. displaying a dialogue) is only able to start while the game state In Control is active, which is set to only be active while the player can be controlled. This way, the interaction will only be available while the player is in control, i.e. it can’t be started during blocked control (e.g. in a cut-scene).

Variable #

Starting a machine can depend on variables having certain values – variables and variable conditions allow creating advanced and complex game mechanics. You can learn more about variables here

Example #

A trigger machine (e.g. starting a cut-scene or auto saving the game upon entering the trigger) is only able to start when the bool variable quest_A_started is enabled. The variable is enabled by another schematic, e.g. through a dialogue with an NPC.

Local Start Variables #

A machine can initialize the local variables of the schematic it starts to defined values. While you can also set them in the schematic, setting them in the machine allows reusing the schematic with different start variables, doing different things or behaving differently.

Examples #

An auto machine creating a tiled level with a random layout gets the level’s size from the local variables. Using two int variables (e.g. columns and rows) to define the size, you can create different level sizes with the same schematic. Level 1 can have a size of 8×8, level 2 a size of 10×8, etc.

A trigger machine will damage the player (reduce the health variable of the player) when he enters the trigger. Using an int variable (e.g. damage) to define the damage that will be done will allow using the scame chematic to do different damage on different machines.

Schematics can also define Machine Start Variables, local variables that will be exposed to machines for quick setup. The machine start variables of the schematic will also be listed here.

Change After Execution #

Machines can automatically change variables after they finished execution. While you can also change variables in schematics, doing this in the machine allows reusing the schematic for different purposes and changing different variables.

Examples #

A trigger machine will add points to the player’s score (e.g. increase an int variable score) when he enters the trigger. To only get the points once, change the bool variable points_A_collected after execution to true and use a variable condition checking for that variable to be false. Using a different variable for each points collection will make them unique and only be collectible once. Changing the variable in the schematic would change the same variable for all machines, requiring to have different schematics for every individual points collection.

A tagged machine will remove (kill) an enemy game object, playing an animation and an audio clip. The resource overrides allow reusing the schematic for different enemies and using different audio clips. To add a kill counter for different enemies (i.e. keep track of how many enemies of different types you’ve killed), increase different int variables for different enemies (e.g. enemy type A increases enemy_A_counter, enemy type B increases enemy_B_counter).