local sqrt = math.sqrt velocitySystem = filteredSystem({ position = T.XyPair, velocity = T.XyPair }, function(e, dt, system) if not e.velocity then return end if sqrt((e.velocity.x * e.velocity.x) + (e.velocity.y * e.velocity.y)) < 1.5 then e.velocity = nil if e.spawnEntitiesWhenStopped then e:spawnEntitiesWhenStopped(system.world) e.spawnEntitiesWhenStopped = nil end system.world:addEntity(e) else e.position.x = e.position.x + (e.velocity.x * dt) e.position.y = e.position.y + (e.velocity.y * dt) end end)