Trigger
The Trigger class extends Actor and creates a shape-based volume in the world that detects when other actors overlap it. Triggers are useful for gameplay logic like entering zones, starting scripted events, teleporting players, or detecting proximity. Supported shapes include spheres, boxes, and capsules.
tip
Trigger is an Actor, so it inherits all functions from Actor.
Constructor
- Blueprint
- Lua
- JavaScript
// Triggers are spawned via Lua scripting.
-- Spawn a sphere trigger
local trig = Trigger(
Vector(0, 0, 200), -- location
Rotator(), -- rotation
Vector(100), -- extent (radius for sphere)
TriggerType.Sphere, -- trigger shape
true, -- visible (debug shape)
function(self, other) -- callback on overlap
print(other:GetName())
end,
Color(1, 0, 0, 0.5) -- debug color
)
// Trigger spawning follows the same pattern via PuerTS or Helix JS bindings.
// Refer to the Lua examples for constructor parameters.
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Location | Vector | (0,0,0) | World position for the trigger. |
Rotation | Rotator | (0,0,0) | World rotation. |
Extent | Vector | (100,100,100) | Shape extents (radius, box half-size, or capsule radius/height). |
TriggerType | enum | TriggerType.Sphere | Shape of the volume -- Sphere, Box, or Capsule. |
bVisible | boolean | false | If true, draws a semi-transparent debug shape. |
CallbackFunction | function | Required | Function called on actor overlap. Receives (self, otherActor). |
Color | Color | (0,1,0,0.5) | Debug color if visible. |
OverlapOnlyClasses | table | {} | Optional array of UClass paths to restrict overlap (e.g., only "/Script/Engine.Pawn"). |
Examples
Safe Zone
- Blueprint
- Lua
- JavaScript
// Triggers are created and managed via Lua scripting.
-- Create a safe zone trigger
local safe_zone = Trigger(
Vector(0, 0, 0),
Rotator(),
Vector(2000, 2000, 500),
TriggerType.Box,
true,
function(self, other)
print(other:GetName() .. " entered the zone")
end,
Color(0, 1, 0, 0.3)
)
// Trigger creation follows the same pattern via PuerTS or Helix JS bindings.
// Refer to the Lua examples for constructor parameters.
note
When bVisible is set to false (the default), triggers are invisible in-game and have no visual representation. Set bVisible to true during development for debugging purposes.