Skip to content

Collider

Class ยท server and client scripts

Collider defines the collision shape, trigger behavior, physical surface overrides, assembly membership, and contact signals of an entity. Access it through entity.Collider after adding Component.Collider.

Kind

Property
Kind: string

Kind sets the collision shape: "Auto" follows the visual Shape (Box, Sphere, Cylinder, or Wedge), or pick "Box", "Sphere", "Cylinder", "Wedge", or "Capsule" explicitly.

Default "Auto"

Trigger

Property
Trigger: boolean

Trigger turns the collider into a non-solid sensor volume that lets bodies pass through while firing Touched and TouchEnded.

Default false

Example

-- Server script in a checkpoint part.
local col = self.Collider
if col then
    col.Trigger = true
end
self:On(Component.Collider.Touched, function(other: Entity)
    print(other.Name, "entered trigger")
end)

Enabled

Property
Enabled: boolean

Enabled turns collision tests on or off for this collider without removing the component.

Default true

Friction

Property
Friction: number

Friction overrides the surface friction of this collider. Call ClearMaterial to revert back to the part's material.

Restitution

Property
Restitution: number

Restitution overrides the bounciness (0 to 1) of this collider. Call ClearMaterial to revert back to the part's material.

Density

Property
Density: number

Density overrides the mass density of this collider. Call ClearMaterial to revert back to the part's material.

Root

PropertyRead only
Root: Entity

Root is the root entity of the welded physics assembly that contains this collider, settling pending welds made on the current tick.

ClearMaterial

Method
ClearMaterial() -> ()

ClearMaterial removes per-collider Friction, Restitution, and Density overrides so the collider inherits values from its surface material again.

Example

-- Server script in a part.
local col = self.Collider
if col then
    col:ClearMaterial()
end

Members

Method
Members() -> { Entity }

Members returns an array of every entity in this collider's welded physics assembly, settling pending welds made on the current tick.

Example

-- Server script in a part.
local col = self.Collider
if col then
    print(#col:Members())
end

Detach

MethodServer only
Detach() -> ()

Detach breaks this collider off its welded assembly on the server so it and its descendants simulate as a separate body.

Example

-- Server script in a welded part.
local col = self.Collider
if col then
    col:Detach()
end

Touched

EventRead only
Touched: Signal<(other: Entity) -> ()>

Touched fires with the other entity when this collider begins overlapping another collider. Connect with entity:On(Component.Collider.Touched, fn).

Example

-- Server script in a pad part.
self:On(Component.Collider.Touched, function(hit: Entity)
    print(hit.Name, "touched")
end)

TouchEnded

EventRead only
TouchEnded: Signal<(other: Entity) -> ()>

TouchEnded fires with the other entity when this collider stops overlapping another collider. Connect with entity:On(Component.Collider.TouchEnded, fn).

Hit

EventRead only
Hit: Signal<(other: Entity, position: vector, normal: vector, speed: number) -> ()>

Hit fires during a physics step with (other, position, normal, speed) when this collider impacts another body. Connect with entity:On(Component.Collider.Hit, fn).

Example

-- Server script in a floor part.
self:On(Component.Collider.Hit, function(other: Entity, position: vector, normal: vector, speed: number)
    if speed > 20 then
        print(other.Name, math.round(speed))
    end
end)