Motion
Get Motion

ReferenceScripting APIMote

Mote

class

A thing in the scene with a place, made of components bound to its layers.

NameMote
Kindclass
Script reaches it asimport { Mote } from "motion" · MotionScene.pickItem() · MotionEvents.moteClick · MotionEvents.hit · MotionEvents.hitEnd · MotionEvents.moteEnter · MotionEvents.moteLeave
Since0.3

Syntax

class Mote { … }

Properties

NameTypeDescription
idpropertyreadonly stringIts id.
namepropertyreadonly stringIts name.
stagepropertyreadonly MotionStageApiThe stage it's on.
alivepropertyreadonly booleanWhether it's still there (not destroyed).
locationpropertyVector3Where it is: the scene's pixels (2D, y down) or its 3D layer's units.
rotationpropertyRotatorHow it's turned: pitch, yaw, roll (degrees; a 2D mote's turn is its yaw).
scalepropertyVector3How big it is, each way.
tagspropertyreadonly Set<string>Its tags.
parentpropertyreadonly Mote | nullThe mote it moves with, or null.
tickingpropertyMotionTickingHow often it ticks.
velocitypropertyreadonly Vector3Its body's speed, as the physics had it this turn ((0, 0, 0) without a body).
angularVelocitypropertyreadonly RotatorHow fast its body turns, degrees a second.

Methods

SignatureDescription
new Mote(): MoteconstructorDon't make one with new: stage.spawn makes a mote of your class and puts it on the stage, and Studio makes the ones placed in the scene.
setLocation(v: Place): voidmethodPuts it somewhere.
addOffset(v: { x?: number; y?: number; z?: number }): voidmethodMoves it by so much.
addLocalOffset(v: { x?: number; y?: number; z?: number }): voidmethodMoves it by so much in its own turned frame (its yaw).
setRotation(r: number | number[] | Rotator): voidmethodTurns it.
addRotation(degrees: number): voidmethodTurns it by so much (its yaw).
setScale(s: number | Place): voidmethodSizes it.
moveTo(target: Place, options?: { seconds?: number; easing?: "linear" | "easeIn" | "easeOut" | "easeInOut" }): Promise<void>methodMoves it there over seconds, eased.
setTimer(seconds: number, fn: () => void, options?: { looping?: boolean }): number +1 moremethodRuns a function after seconds (and every seconds, looping): seconds first, as scene.every has them.
clearTimer(id: number): voidmethodStops a timer.
attachTo(parent: Mote | null): voidmethodMakes it move with another (null: on its own again), keeping where it is now.
detach(): voidmethodOn its own again.
enableInput(): voidmethodHears the pointer again.
disableInput(): voidmethodHears the pointer no more (clicks pass through it).
hasTag(tag: string): booleanmethodWhether it has a tag.
addTag(tag: string): voidmethodGives it a tag (64 at most).
removeTag(tag: string): voidmethodTakes a tag away.
component<C extends Component>(name: string): C | nullmethodOne of its components, by name.
destroy(): voidmethodTakes it out of the scene.
setVelocity(v: Place): voidmethodGives its body a speed.
applyImpulse(v: Place): voidmethodPushes its body: mass times the speed it gains.
applyForce(v: Place): voidmethodA force on its body for the next step: mass times the speed it gains a second.
applyTorque(t: number | number[] | Rotator): voidmethodA turning push on its body: the degrees a second it gains, times its inertia.
sleep(): voidmethodPuts its body to sleep: it rests until something touches or pushes it.
wake(): voidmethodWakes its body.
onStart(): voidmethodIt started (what a class overrides).
onTick(dt: number): voidmethodEach of its ticks (as often as its ticking says).
onEnd(): voidmethodIt's being destroyed.
onClicked(hit: MotionHit): voidmethodIt was clicked.
onPointerEnter(): voidmethodThe pointer came over it.
onPointerLeave(): voidmethodThe pointer left it.
onHit(other: Mote): voidmethodIts body started touching another's.
onHitEnd(other: Mote): voidmethodIts body stopped touching another's.
onDragStart(): voidmethodThe pointer started dragging it (a DragComponent).
onDrag(location: Vector3): voidmethodThe pointer dragged it.
onDragEnd(): voidmethodThe pointer let it go.

See also

MotionStageApi · Vector3 · Rotator · MotionTicking