Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

Godot Triggers

An asset by sosigmidget
The page banner background of a mountain and forest
Godot Triggers hero image

Quick Information

0 ratings
Godot Triggers icon image
sosigmidget
Godot Triggers

An attempt to bring Source-like triggers and outputs in Godot.Extends the default Area2D/3D nodes.

Supported Engine Version
4.5
Version String
1.0
License Version
GPLv3
Support Level
community
Modified Date
19 hours ago
Git URL
Issue URL

Godot Triggers

An attempt to bring Source-like triggers and outputs in Godot, albeit in a limited state.

Usage

  1. Simply drag and drop the Trigger2D/Trigger3D into your scene and give it a CollisionShape2D/3D.
  2. IMPORTANT: Set the collision mask of the trigger! Any areas/bodies in the layer it scans will activate the trigger. The collision layer of the trigger itself has no effect.
  3. Add the outputs in the Inspector tab.

The output system

README sample output list

The way outputs are handled are, as the description says, similar to how the Source engine handles outputs. Here, Outputs are Resources that contain five variables. They ultimately just describe what method (and additional arguments) to call on a Node.

Variable Type Default value Description Hammer equivalent
output String area_entered What causes this output to fire. Examples include area_entered, area_exited, etc. My Output
target NodePath The node we are targeting. Target Entity
target_method StringName The name of the method (function) we're calling to the target. Target Input
arguments Array The arguments to be passed along when calling the target method. Parameter
delay float 0.0 The number of seconds to wait after the output event occurs before firing. Delay

Note that the Triggers have assertions for output, target and target_method.

By default, the Triggers only support four outputs:

  • area_entered/body_entered
  • area_exited/body_exited

You can, however, extend the trigger to add more outputs.

Adding custom outputs

In this section we will add the output "interacted" that will be fired when the player is in the trigger and presses the ui_accept button (spacebar).

  1. Make a new array to store your custom outputs. (`_on_interacted_outputs)
  2. Add Outputs via the _ready() method.
func _ready() -> void:
    super._ready()
    
    for _output: Output in outputs:
        if _output.output == "interacted":
            _on_interacted_outputs.append(_output)
  1. In your code for checking input and player collisions, add _emit_outputs(_on_interacted_outputs).

Adding outputs via code

This is mostly useful for when you're extending the Trigger script for more specific uses. Here is a direct example from my game, which targets a specified "target location" Node, which has a method that essentially sets the player's global position to its global position.

func _ready() -> void:
    super._ready()
    
    var output: Output = Output.new()
    output.target = tele_target.get_path()
    output.target_method = "teleport"
    
    _on_area_entered_outputs.append(output)

Known limitations

  • Source's outputs have refires. This one does not.
  • There are also no special targetnames unlike in Source, where you can call !activator to, I don't know, deal 10000 damage to the players that touch it during a Payload explosion or something. Wildcards are also a no-go (setup_door_* to call setup_door_top and setup_door_bottom). This is because the target in Outputs require a NodePath, rather than a simple string name.
  • There are no ways to view all the outputs fired onto a Node, unlike Source.

An attempt to bring Source-like triggers and outputs in Godot.

Extends the default Area2D/3D nodes.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Godot Triggers icon image
sosigmidget
Godot Triggers

An attempt to bring Source-like triggers and outputs in Godot.Extends the default Area2D/3D nodes.

Supported Engine Version
4.5
Version String
1.0
License Version
GPLv3
Support Level
community
Modified Date
19 hours ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers