Skip to main content

Physics

local physics = game:get('Physics')

Physics service provides signals and utilities related to physics world.

Signals

onCollisionStart:connect(handler: (event: CollisionEvent): void): void

Triggered when two entities start colliding.

local physics = game:get('Physics')
physics.onCollisionStart:connect(function(e)
local a = e.a
local b = e.b
end)

Parameters:

  • event: Collision event
    • event.a: First collided entity. The value is an entity.
    • event.b: Second collided entity. The value is an entity.

onCollisionEnd:connect(handler: (event: CollisionEvent): void): void

Triggered when two entities end colliding.

local physics = game:get('Physics')
physics.onCollisionEnd:connect(function(e)
local a = e.a
local b = e.b
end)

Parameters:

  • event: Collision event
    • event.a: First collided entity. The value is an entity.
    • event.b: Second collided entity. The value is an entity.