API Reference › Math › Math.move_toward
method

Math.move_toward

Math.move_toward(from, to, delta) -> fixed

Moves from toward to by at most delta, never overshooting — when the gap is smaller than delta it returns exactly to. Unlike Math.lerp, which eases by a fraction of the remaining distance, this moves at a constant rate, which is what you want for turrets, meters, and UI values that should approach a target steadily and then stop.

Example

program Demo {
  handler Step phase Update {
    health_shown = Math.move_toward(health_shown, health, 2.0)
  }
}
← All symbols