Skip to content

Trigger Area

Physics detection volume that triggers onEnter and onExit overlap events without rigid collisions.

Type: AreaNode · Category: Physics & Collision · Also found as: area

Property Type Default Description
overlapCount integer 0 Bodies overlapping now. Range 0 to 100. Runtime state: read-only, not saved.
hasOverlaps boolean false Anything overlapping now. Runtime state: read-only, not saved.
debugColor color #a855f7ff Outline colour when nothing overlaps.
activeColor color #ec4899ff Outline colour while something overlaps.

Plus the common properties every node has.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

Connects a handler to one of this node’s events: body_entered (A body entered the area), body_exited (A body left the area); the tree events; custom ones.

self.node:connect("body_entered", function(value, source) Log.info("body_entered") end)
  • event AreaNodeEvent|string
  • handler fun(value: any, source: AreaNode)

Returns integer id Connection id for disconnect

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("debugColor")
  • path AreaNodeProperty|string

Returns any

Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.” a field of the node’s script.

self.node:set_property("debugColor", "#ff8800")
  • path AreaNodeProperty|string
  • value any
  • y? number

Checks whether any physics nodes are currently inside this sensor area.

if self.node:get_node("Hitbox"):area_is_overlapping() then self:take_damage(1) end

Returns boolean

Returns the number of bodies currently overlapping this sensor area.

local count = self.node:get_node("Zone"):area_get_overlap_count()

Returns number

Returns an array of all nodes currently overlapping this sensor area.

for _, n in ipairs(self.node:area_get_overlapping_nodes()) do Log.info(n:get_name()) end

Returns Node[]

{
"type": "AreaNode",
"name": "TriggerArea",
"position": [
0,
0
],
"properties": {
"debugColor": "#a855f7ff",
"activeColor": "#ec4899ff"
}
}