object.isBodyActive

Type Boolean
Object Body
Library physics.*
Revision Release 2024.3703
Keywords body, isBodyActive
See also object.isAwake

Overview

Used to set or get the body's current active state. Inactive bodies are not destroyed but they are removed from the physics simulation and cease to interact with other bodies.

Gotchas

If this property is set to false on an active object currently in collision state with another, a collision with a phase of "ended" will immediately be triggered. Likewise, if this property is set to true on an inactive object currently in collision state with another, a collision with a phase of "began" will immediately be triggered.

Example

-- Create a rectangle
local myRect = display.newRect( 0, 0, 100, 100 )

-- Add a body to the rectangle
physics.addBody( myRect, "dynamic" )

-- Set the rectangle's active state
myRect.isBodyActive = false