function getLocalVelocity(entity) if not entity:isValid() then return end return entity:worldToLocal(entity:getVelocity() + entity:getPos()) end