Skip to content

Body

Class ยท server and client scripts

Body configures how an entity simulates under physics: motion mode, damping, gravity scaling, axis locks, mass, sleep state, and force or impulse methods. Access it through entity.Body after adding Component.Body.

Motion

Property
Motion: string

Motion sets how the physics solver moves the body: "Static" locks it in place, "Dynamic" simulates gravity, collisions, and forces, and "Kinematic" moves only when scripts write its transform.

Default "Static"

Example

-- Server script in a part.
local body = self.Body
if body then
    body.Motion = "Dynamic"
end

Enabled

Property
Enabled: boolean

Enabled turns physics simulation on or off for this body without removing the component.

Default true

GravityScale

Property
GravityScale: number

GravityScale multiplies world gravity for this body. 1 is normal gravity, 0 is weightless, and negative values pull upward.

Default 1

LinearDamping

Property
LinearDamping: number

LinearDamping slows linear motion over time. 0 applies no drag.

Default 0.3

AngularDamping

Property
AngularDamping: number

AngularDamping slows angular spin over time. 0 applies no drag.

Default 0.5

LockPositionX

Property
LockPositionX: boolean

LockPositionX prevents the body from moving along the world X axis.

Default false

LockPositionY

Property
LockPositionY: boolean

LockPositionY prevents the body from moving along the world Y axis.

Default false

LockPositionZ

Property
LockPositionZ: boolean

LockPositionZ prevents the body from moving along the world Z axis.

Default false

LockRotationX

Property
LockRotationX: boolean

LockRotationX prevents the body from rotating around the world X axis.

Default false

LockRotationY

Property
LockRotationY: boolean

LockRotationY prevents the body from rotating around the world Y axis.

Default false

LockRotationZ

Property
LockRotationZ: boolean

LockRotationZ prevents the body from rotating around the world Z axis.

Default false

Mass

PropertyRead only
Mass: number?

Mass is the total mass of the body's assembly in kilograms, or nil while the body is not simulated.

Sleeping

PropertyRead only
Sleeping: boolean

Sleeping is true while the solver has put the body to rest until a force, contact, or transform change wakes it.

ApplyImpulse

Method
ApplyImpulse(impulse: vector, at: vector?) -> ()

ApplyImpulse applies an instantaneous linear impulse v in world space, optionally at world point at.

Example

-- Server script in a dynamic part.
local body = self.Body
if body then
    body.Motion = "Dynamic"
    body:ApplyImpulse(Vector3.new(0, 50, 0))
end

ApplyForce

Method
ApplyForce(force: vector, at: vector?) -> ()

ApplyForce applies a continuous linear force v in world space during the next physics step, optionally at world point at.

Example

-- Server script in a dynamic part.
local body = self.Body
if body then
    body:ApplyForce(Vector3.new(0, 100, 0))
end

ApplyTorque

Method
ApplyTorque(torque: vector) -> ()

ApplyTorque applies a continuous angular torque v around world axes during the next physics step.

Example

-- Server script in a dynamic part.
local body = self.Body
if body then
    body:ApplyTorque(Vector3.new(0, 10, 0))
end

ApplyTorqueImpulse

Method
ApplyTorqueImpulse(impulse: vector) -> ()

ApplyTorqueImpulse applies an instantaneous angular impulse v around world axes.

Example

-- Server script in a dynamic part.
local body = self.Body
if body then
    body:ApplyTorqueImpulse(Vector3.new(0, 5, 0))
end