local sqrt = math.sqrt filteredSystem("velocity", { position = T.XyPair, velocity = T.XyPair }, function(e, dt, system) if sqrt((e.velocity.x * e.velocity.x) + (e.velocity.y * e.velocity.y)) < 2 then -- velocity = nil else e.position.x = e.position.x + (e.velocity.x * dt) e.position.y = e.position.y + (e.velocity.y * dt) end end) filteredSystem("drag", { velocity = T.XyPair, drag = T.number }, function(e, dt, system) local currentDrag = e.drag * dt e.velocity.x = e.velocity.x - (e.velocity.x * currentDrag * dt) e.velocity.y = e.velocity.y - (e.velocity.y * currentDrag * dt) end)