Motion
Get Motion

ReferenceScripting APIBodyComponent

BodyComponent

class

A mote's body, which Motion's physics moves.

NameBodyComponent
Kindclass
Script reaches it asimport { BodyComponent } from "motion"
Since0.3

Syntax

class BodyComponent extends Component { … }

Properties

NameTypeDescription
namepropertyreadonly stringIts name on its mote.
layerpropertyreadonly stringIts layer's id.
visiblepropertybooleanWhether its layer shows.
opacitypropertynumberIts layer's opacity, 0 to 1.
motepropertyreadonly MoteIts mote.
velocitypropertyVector3Its speed.
angularVelocitypropertyreadonly RotatorHow fast it turns, degrees a second.

Methods

SignatureDescription
new BodyComponent(name?: string, layer?: string): BodyComponentconstructorBinds a layer to a mote by hand. A mote's components are made with it, from the layers it's given in Studio, so you rarely need this.
set(key: string, value: SettingValue): voidmethodChanges one of its layer's settings.
animate(key: string, value: string | number, seconds: number, options?: MotionAnimateOptions): Promise<boolean>methodMoves one of its layer's settings.
stopAnimating(key?: string): voidmethodStops its layer's moves.
get(key: string): SettingValue | undefinedmethodOne of its layer's settings, as scene.get.
read(key: string): SettingValue | undefinedmethodOne of its layer's settings as last drawn, as scene.read.
show(visible?: boolean): voidmethodShows (or hides) its layer.
hide(): voidmethodHides its layer.
setVelocity(v: Place): voidmethodGives it a speed.
applyImpulse(v: Place): voidmethodPushes it: mass times the speed it gains.
applyForce(v: Place): voidmethodA force for the next step: mass times the speed it gains a second.
applyTorque(t: number | number[] | Rotator): voidmethodA turning push.
sleep(): voidmethodPuts it to sleep.
wake(): voidmethodWakes it.

See also

SettingValue · Mote · Vector3 · Rotator