Evaluate State transitions with the Signal Evaluate node

If you haven’t completed the previous tutorials yet, please complete them starting from Basic Usage.

This time, let’s use the Signal Evaluate node to evaluate the transition from State.
The contents are as follows.

  • Create a GameObject with a Logic Behavior component.
  • Open and edit the graph in the Logic Editor window.
  • The Signal Evaluate node determines the passage of time and transitions accordingly.
  • Transitions are determined by multiple conditional judgments.

Create a new scene

If you have other scenes open, it will be confusing, so create a new scene.

  • Select File > New Scene from the menu.
  • In the New Scene window, select Basic (URP).
  • Click the Create button

Creating a GameObject with Logic Behavior

Create a GameObject with a Logic Behavior component added to the Scene.

  • Click the + button in Hierarchy.
  • Select Logic Toolkit > Logic Behavior from the menu.
  • Confirm the name by pressing Enter.

Opening the Logic Editor window

Graphs of Logic Behavior components are edited in the Logic Editor window.
If the window is not displayed, select a GameObject and click the “Edit” button in the Inspector to display it.

  • Select the Logic Behavior object
  • Click the Edit button on the Logic Behavior component in the Inspector window.

If the Logic Editor window is already displayed, the graph will switch in conjunction with selecting a GameObject in the Hierarchy window.

Creating a State node

Create a State node.

  • Drag the output execute port of the Start node
  • Drop it near the right side to open the node creation menu
  • Select the Scripts tab
  • Select State
  • Confirm the node name with the Enter key

Creating a Signal Evaluate node

Create a Signal Evaluate node.

  • Drag the output signal port of the Start node
  • Drop it near the right side to open the node creation menu
  • Select the Scripts tab
  • Select Signals > Signal Evaluate from the list
  • Confirm the node name with the Enter key

About Signal Wire

The output signal port of the State node and the input signal port in the Inputs list of the Signal Evaluate node are connected by a signal wire.
This signal wire is a wire (connection line) that sends a signal to evaluate the state transition conditions.

The output signal port in the header of the State node becomes active while the State node is executing, and the transition condition is evaluated in the connected Signal Evaluate node.

The Completed ports of Wait For Seconds and Button.onClick, which we used in the State node last time, are also output signal ports.
If you connect the Completed port to the Signal Evaluate node with a signal wire, a signal will be sent when the processing is complete.

For now, just remember that when a signal becomes valid, the Signal Evaluate node can be used to determine whether to transition.

Add Wait For Seconds to the Signal Evaluate node

Add Wait For Seconds to the Conditions of the Signal Evaluate node.

  • Click the + button in Conditions of the Signal Evaluate node to open the menu for adding node components.
    (Like the State node, the + button for inserting appears when you hover the mouse over it.)
  • Select the Scripts tab.
  • Select Tasks > Wait For Seconds from the list.

Wait For Seconds setting

Set it to wait 1 second.

  • Set the Seconds field to 1

Create a Debug.Log Action node

Create an Action node so that Debug.Log will be executed after 1 second.

  • Drag the output signal port of the Signal Evaluation node
  • Drop it near the right side to open the node creation menu
  • Select the Scripts tab
  • Select Actions > Debug > Debug.Log from the list
  • Confirm the node name with the Enter key

Debug.Log Settings

Set the message to be output to the console.

  • Set the Message field to Completed

Check the play so far

Let’s play it once and check how it works.
The graph looks like this:

Press the play button to see how it works.

  • Verify that Completed is displayed on the console after 1 second has elapsed.

If the Console window is not visible, select Window > General > Console from the menu to display it.

Added Float Compare to the Signal Evaluate node.

Using Wait For Seconds alone probably won’t tell you any difference from using it directly in the State node.
So let’s add some more transition conditions.
This time, add Float Compare to the Conditions.

  • Click the + button in Conditions of the Signal Evaluate node to open the menu for adding node components.
    (Like the State node, the + button for inserting appears when you hover the mouse over it.)
  • Select the Scripts tab.
  • Select Evaluators > Float > Float Compare from the list.

Float Compare Settings

Let’s compare the float comparison to the “distance to the NPC being tracked” and determine that it is true if it is within a certain range.

  • Set the Comparison Op field to <= (Less Than Or Equal)
  • Set the Value 1 field to 10
    (assuming the distance to the current target)
  • Set the Value 2 field to 5
    (assuming the range of judgment)

Play and check

Once you’ve done this, your graph will look like this:

Press the play button to see how it works.

  • Confirm that there is no output to the Console even after 1 second has passed.
  • Drag the Value 1 field of Float Compare to decrease it, and confirm that when the number drops below 5, Completed is output to the Console.

If the Console window is not visible, select Window > General > Console from the menu to display it.

If the Value 1 field is set to 5 or less from the beginning, the transition will occur immediately after 1 second has passed.
In other words, the condition for the transition is that more than 1 second has passed and the Value 1 field is 5 or less.

Signal Complement

Logical operations for judgment

The Inputs and Conditions fields of the Signal Evaluation node also have settings for Invert and And/Or.
This setting allows you to evaluate complex transitions that combine multiple judgments.

  • Enabling Invert will invert the judgment result.
  • Setting it to And will perform an And operation on the judgment results up to the next higher and the judgment result itself.
  • Setting it to Or will perform an Or operation on the judgment results up to the next higher and the judgment result itself.

In this case it is Wait For Seconds [AND] Float Compare.
Therefore, the transition condition is “1 second elapsed [AND] Value 1 <= Value 2“.

Other signal-related nodes

There are two other types of nodes that can be used to determine signals.
See the manual for more information.

Next time

Next time, we will do How to use BehaviorTree node

If you try the trial version and like it, you can purchase it from the Asset Store.