API Reference › Motion › Motion.to
method

Motion.to

Motion.to(entity, from, to, dur, ease)

Starts a value tween on an entity's Motion component: it sets from, to, dur and ease, resets the timer, and seeds value at from, so the engine interpolates value from from to to over dur ticks and latches done at the end. One call replaces setting five fields by hand — a health bar sliding, a door opening, an alpha fade. A no-op if the entity has no Motion. Integer and deterministic.

Parameters

entitythe entity carrying Motion
durthe duration in engine ticks
ease0 linear, 1 in, 2 out, 3 in-out

Example

program Demo {
  property Motion { ticks: int = 0, dur: int = 0, from: int = 0, to: int = 0, ease: int = 0, value: int = 0, done: int = 0 }
  model Door { Motion }
  entry {
    spawn Door { Motion { } }
    let e = World.query_next(World.prop_id("Motion"), 0)
    Motion.to(e, 0, 64, 30, 2)          # slide 0 -> 64 over 30 ticks, ease-out
    quit()
  }
}
← All symbols