April
27
2015

Learn more about auto machines and what you can use them for.

Auto machines are Unity components that are added to game objects. They’re mostly used for initializing things (e.g. spawning prefabs when a level was loaded) or starting repeating schematics (e.g. for player or camera controls, using the Restart Schematic node).

An auto machine component can be added through the components menu (Makinom > Machines > Auto Machine) or the scene wizard (Add Machine > Auto Machine). A game object with an auto machine is represented in the Unity scene view by this gizmo icon:

AutoMachineComponent Icon

You can learn more about machine components in general and their basic settings in this how-to.

Start Types

An auto machine is started when a game object is initialized/enabled or destroyed/disabled.

Start

Started when the machine’s game object or component is first added to the scene. It’s implemented in the component’s Start function.

The start can optionally be delayed by a defined amount of time, and repeat the execution after a defined amount of time.

Example

This start type can be used to show a main menu when starting the game. Use a Show Dialogue node to create menus (Choice dialogue type).

Enable

Started each time when the machine’s game object or component is enabled. It’s implemented in the component’s OnEnable function.

The start can optionally be delayed by a defined amount of time, and repeat the execution after a defined amount of time.

Example

This start type can be used to reset variables or values of the game object each time it’s enabled. Use a Change Variables node to change variables, or use a Change Fields node to change other components’ field values.

Disable

Started when the machine’s game object is disabled. It’s implemented in the component’s OnDisable function.

Example

This start type can be used to reenable the game object after some time. Use a Wait node to wait for a defined amount of time and an Activate Object node to enable the game object.

Destroy

Started when the machine’s game object is destroyed. It’s implemented in the component’s OnDestroy function.

Example

This start type can be used to store the position of the game object before it’s destroyed. Use a Change Variables node to store the position of a game object into a Vector3 variable.

Level Was Loaded

Started after a new level was loaded. It’s implemented in the component’s OnLevelWasLoaded function.

The start can optionally be delayed by a defined amount of time, and repeat the execution after a defined amount of time.

Example

This start type can be used to reset variables on persistant game objects after loading a new scene. Game objects can be made persistant (i.e. they wont be destroyed when loading a new scene) by using a Don’t Destroy on Load node. Use a Change Variables node to change variables.