[Deep Dive into AGMaker] Script Snippet - Sending and Detecting Signals

Script Effects

Divided into two scripts.
One demonstrates how to use Condition: Detect Signal to notify the VS state machine of events occurring within the GD script.
The other demonstrates how to use Action: Emit Signal within the VS state machine to trigger logic in the GD script.

Key Points

  1. player must point to your actual game object.
  2. This snippet briefly demonstrates using Godot’s native is_on_floor method to notify the game object to respond.
  3. In the game object, use Detect Signal and change the target signal name to on_floor_event, leaving parameters set to none.
  4. After using the Emit Signal action in the visual script, a new signal is dynamically added to the signal list, which can be used directly. Connect it to a function within a GD script.

Core

How to use Condition - Detect Signal

extends Node

signal agm_send_signal(signal_name, parameter)

@onready var player: GameObject = $".."
var was_in_air = false

func _ready() -> void:
	agm_send_signal.connect(Callable(player, "receive_signal"))

func _physics_process(_delta):
	if player.is_on_floor():
		agm_send_signal.emit("on_floor_event", null)
		pass

How to use Action - Emit Signal

If this action is used, the VS state machine will dynamically register a new signal.
You can then receive it in a GDScript script.