Getting Started with Trigger Edit

July 4, 2022

Getting Started with Trigger Edit

Introduction to trigger edit

The editor provides a way of visual programming. You can use the trigger editor to write game logic, such as game flow, interactive effects, and combat feedback. This method does not require developers to have professional programming skills. When initially constructing the game framework, using the trigger editor will help you quickly achieve game effects.

At present, the game Part that can write visual triggers are: blocks, entities, items, skills, missiles, regions, and parts. You can find the trigger edit button in the property panel of these Part. Click the trigger edit button to open the trigger editor to edit the current object.

Node introduction

Nodes are the most basic entity in trigger editing. Nodes are divided into two types: trigger nodes and action nodes. By connecting and organizing these nodes, the desired game logic can be realized. As shown in the figure below, each panel is a node.

Trigger Node

The root node in each trigger graph is the trigger node, which is the beginning of all the logic of the current graph.

When the object in the game triggers the specified trigger (for example, when the game starts, when the entity enters the game, etc.), the corresponding trigger node will be triggered, and its internal action nodes will be executed in order.For example, the node in the figure below is the trigger node:

The trigger nodes available for different objects are also different, and only the trigger node triggered by the current object can be used in the trigger graph of the current object. For example: You cannot use the trigger node “When the block is clicked” in the entity’s trigger chart, because the entity cannot trigger the trigger.

In Create Trigger Graph, the corresponding trigger node will be created at the same time. The trigger node is unique in a graph, and it cannot be deleted, copied, cut, etc.

A trigger node usually consists of the following parts:

Index Name Description
1 Return value type The return value type of the current node (Void means no return value). But since the trigger node has no return value, it can be ignored.
2 Node name Node name of the current node
3 Execution sequence When the trigger is triggered, the action nodes connected to the execution interface will be executedfrom top to bottom.

Click the + sign to add a new execution interface, click the delete button to delete the currently selected execution interface, or drag the execution interface to adjust the execution order.

4 Execution interface Used to connect the action node to be executed.

Action Node

In a trigger graph, except for the trigger node, the other nodes are all action nodes.

The action node is used to perform specific functions. It can perform various specific logics, such as obtaining the value of a variable, modifying the state of an object, and making logical judgments.For example, the nodes in the figure below are action nodes:

An action node usually consists of the following parts:

Index Name Description
1 Return value type The return value type of the current node (Void means no return value), Only when the return value type of node A is the same or compatible with the parameter type of node B, the return value interface of node A can be connected to the parameter interface of node B.
2 Node name Node name of the current node
3 Return value interface Used to pass the return value of the current node to other nodes. Drag a wire from the interface to connect to the return value interface with the same or compatible data type, which means that the return value is assigned to the connected parameter.
4 Parameter Execute the parameters required by the current node. The parameters marked with * are required parameters. If the required parameters are not assigned, the node will not be executed and an error will be reported.

There are two ways to assign values to parameters:
One is to directly fill in the parameter value, such as “HP” in the above figure, and you can directly enter the parameter value in the input box. However, some parameters cannot be directly input parameter values, such as the “entity” in the above figure.
The other is to use the return value of other nodes as the parameter value of the current parameter by connecting the return value interface of other nodes.
Only one of the two methods can be selected. When the return value of other nodes is used as the parameter value, the parameter value cannot be filled in.

5 Parameter Type The parameter type of the current parameter, Only when the return value type of node A is the same or compatible with the parameter type of node B, the return value interface of node A can be connected to the parameter interface of node B.
6 Parameter interface Used to receive the return value of other nodes and use the return value as the parameter value of the current parameter. Drag out the connection from the interface and connect it to the return value interface with the same or compatible data type, On the return value interface, it means assigning the connected return value to the parameter.

Operation introduction

Create trigger

When the trigger editor is opened for the first time, the editing canvas is blank because no trigger chart has been created yet.

Click the “New” button in the middle of the canvas or the New button in the toolbar to create a new trigger chart.

When creating a new one, the editor will list all the triggers that the current object can trigger, and you can choose to create a new trigger that needs to be edited. The same trigger of the same object can only be created once, and the created trigger will be grayed out.

Delete trigger

Click the delete button in the toolbar to delete the trigger currently being opened. It should be noted that after the trigger is deleted, all nodes in the corresponding trigger graph will be deleted and cannot be undone.

Create Node

For trigger nodes, when a trigger is created, the trigger node corresponding to the trigger is automatically created.

For action nodes, you can create new ones in two ways:

1.Hold down the mouse and drag on the parameter interface, drag to a blank space and release the mouse, a candidate list of action nodes will pop up (only nodes that match the current parameters will be displayed in the candidate list).

2.Double-click a parameter interface,the candidate list of action nodes will also pop up (only nodes that match the current parameters will be displayed in the candidate list).

Double-click the action node that needs to be created in the candidate list, the node will be created in the canvas and automatically connected to the parameters.

Delete / Cut / Copy Node

Select the node that needs to be deleted/cut/copied in the canvas (you can use the mouse to select or hold down Ctrl for multiple selection), and then click the right mouse button on the selected node to delete/cut/copy the selected node. You can also operate it with shortcut keys, delete: Delete key, cut: Ctrl+X, copy: Ctrl+C.

Merging/Expanding Nodes

In the process of making a game, there may be more and more nodes in the canvas. For the convenience of reading and managing the nodes, you can merge the nodes into a node combination:

1.Select the nodes that need to be merged (you can use the mouse to select or hold down Ctrl for multiple selection), click the right mouse button and select “Merge”, you can pack them into a node combination.

2.Click the edit button to the right of the node combination name, you can customize the name of the node combination.

Merging nodes will not affect the original logic of the nodes,it just “hides” the nodes.

If you want to cancel the merge or modify the logic in the combination, click the right mouse button on the node combination and select “Expand”.