Skip to main content
Version: 2026.6

Task System Graph and Nodes

The TaskSystem GameObject contains a script component called “GraphBehaviour”. On the component's inspector there's a button called “Open Graph”. By clicking on it you can access the graph window where you can create all your tasks with their associated detectors.

The Sample Task Scene: the TaskSystem GameObject, its Graph Behaviour component with the Open Graph button, and the graph window

In the Graph window you can create tasks by pressing the right click on your mouse, then hit "Create Node" and choose the task you want to create from the list of proposed nodes.

When a new Task Node is added to the graph, a game object of the same node appears in the hierarchy. The game object has a Task listener child, and, for the nodes that detect an action, a Detector child:

  • Task listener: Manage the triggering of actions and events by referencing task system events.
  • Detector: Manage the triggering of actions and events by referencing specific actions. The actions depend on the type of node selected

The nodes in the graph window have the "Next" and "Dependencies" fields. These are used to handle the logic and flow of the taskSystem.

ComponentList

By completing all the dependencies is how the task progresses to the node attached to the "Next" slot.

Building the graph from an editor script​

The graph window is not the only way to build the graph: an editor script can create the nodes and the links, which helps when a scene has many tasks, or when you generate scenes from code. Put the script in an Editor folder.

using System.Linq;
using SPACS.Graphs;
using SPACS.Tasks;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;

public static class BuildTaskGraph
{
[MenuItem("Tools/Build task graph")]
private static void Build()
{
GraphBehaviour graphBehaviour = Object.FindFirstObjectByType<GraphBehaviour>();
IGraph graph = graphBehaviour.Value;

string[] descriptions = { "Open the door", "Press the button", "Leave the room" };
TaskNode previous = null;

for (int i = 0; i < descriptions.Length; i++)
{
TaskNode node = (TaskNode)Node.GenerateNode(typeof(TaskNode));
node.Name = "Task " + (i + 1);
node.Description = descriptions[i];
node.ShowInUI = true;
node.Position = new Vector2(300f * i, 0f);

graph.AddNode(node);

if (previous != null)
{
Link(graph, previous, "next", node, "input");
}

previous = node;
}

EditorUtility.SetDirty(graphBehaviour);
EditorSceneManager.MarkSceneDirty(graphBehaviour.gameObject.scene);
}

// The graph keeps each link on both ports: add it in both directions.
private static void Link(IGraph graph, Node from, string outputPort, Node to, string inputPort)
{
Port output = from.Ports.First(p => p.Name == outputPort);
Port input = to.Ports.First(p => p.Name == inputPort);

graph.AddLinkBetween(output, input);
graph.AddLinkBetween(input, output);
}
}
  • GraphBehaviour.Value is the graph of the TaskSystem GameObject. Node.GenerateNode creates a node, and AddNode adds it to the graph and creates its GameObject, with its Task listener, under the TaskSystem.
  • The ports of a task are named input, next and dependencies. Link next of a task to input of the following one for a chain; to make a task depend on others, link its dependencies to their input.
  • Add the nodes in the order of the chain: the task system treats the last node added as the last task, and ends the training when it is completed.
  • The node has no title: the task panel shows its Description.
  • AddNode picks the first component class it finds that can hold a task and logs a warning when it finds several: check that each new GameObject carries a Task Virtuademy component.

Task System Multiplayer setup

In order to make the taskSystem work in multiplayer you simply have to tick the "Is Networked" field in the TaskSystemVirtuademy and add the "TasksRPCManagerPlaceholder" to the TaskSystem gameObject. Check the Example Scene in the package to check how to better manage a multiplayer task flow.

The TaskSystem GameObject in the Sample Task Scene: Is Networked ticked on the Task System Virtuademy component, and the Tasks RPC Manager Placeholder added with its Scene Object Id