Using StageTrigger.tscn
Last updated
Last updated
StageTrigger.tscn
is a node that automatically activates and deactivates all of its child .
Sometimes, connecting signals from other nodes may be inefficient because the same node would need to be added for multiple scenes. Other times, it is impractical because there is no specific object tied to a trigger's activation. To solve this, we can use StageTrigger.tscn
instead.
To use StageTrigger.tscn
, follow the steps below:
Instance StageTrigger.tscn
.
Add a CollisionShape3D
as a child node.
Select the CollisionShape3D
node, and set its Collision Shape property in the inspector.
Adjust the StageTrigger.tscn
node's properties as needed.
Notes about
StageTrigger.tscn
and Collision Shapes:
Try to reuse collision shapes from other
StageTrigger.tscn
nodes. instead of creating new ones. This can be done by copying and pasting the previousStageTrigger.tscn
's collision shape.
StageTrigger.tscn
calculates whether the player is moving forward or backwards relative to the level's path, so try to align its position as close to the path as possible.Barring a few exceptions, try to make the collision shape extend at least 15 units off the ground so the player cannot simply jump over it.
The typically CollisionShape is a
BoxShape3D
with extents of(15, 20, 2.5)
and a local position of(0, 8, 0)
.
One Shot - Enable this if the StageTrigger.tscn
node should only be allowed to activate once.
Trigger Mode - Determines how the stage trigger will be activated.
OnEnter - Only activate when the player enters the CollisionShape3D.
OnStay - Activate when the player enters the CollisionShape3D, deactivate when the player exits.
OnExit - Only Activate when the player exits the CollisionShape3D.
Enter/Exit Mode - Determines when activation can happen. Enter Mode
is not available when Trigger Mode
is set to OnExit
, and Exit Mode
is note available when Trigger Mode
is set to OnEnter
.
Both Ways - Process trigger regardless of the player's entrance/exit direction.
Moving Forward - Only process trigger logic when the player is moving forward in the level.
Moving Backward - Only process trigger logic when the player is moving backwards in the level.
Activated
- Emitted when the StageTrigger.tscn
node becomes active.
Deactivated
- Emitted when the StageTrigger.tscn
node becomes in inactive.
Respawned
- Emitted when the the player respawns.
Additionally, most static triggers such as Culling Maps and Events use StageTrigger.tscn
to determine when to be activated by the player.
StageTrigger.tscn
forms the backbone of all stage triggers in . It is most commonly used for and , as they typically remain the same between stages.