Capítulo 251 de 411

Chapter 251: InertiaPlugin.track()

Core Idea

Starts automatically tracking the velocity of the given properties on a target every tick, so later code (or an inertia tween) can read that velocity without manually recording position/time samples.

Reference Tables

ParameterTypeDescription
targetElement | String | Arrayelement(s) to track
propsStringcomma-delimited property names, e.g. "x,y,rotation"

Returns: Array of VelocityTracker objects (one per target).

Code Examples

InertiaPlugin.track(obj, "x,y");
// later:
let vx = InertiaPlugin.getVelocity(obj, "x");
  • What it demonstrates: capturing velocity for later use, e.g. feeding a throwProps-style inertia tween.

Key Takeaways

  1. Only the last 2 samples are kept per property — no memory buildup over time.
  2. Works even with getter/setter (function-based) properties.

Connects To

  • VelocityTracker: the object this returns; most usage goes through InertiaPlugin directly rather than the tracker instance.