

vector_line ={}

function vector_line:frame()
    if (not ba.getCurrentGameState() == GS_STATE_GAME_PLAY) 
        or (not mn.isInMission())
        or hu.HUDDisabledExceptMessages
        or (not hu.HUDDrawn)
        then
        return
    end
    local plr = hv.Player
    -- only continue if we can get valid player handle
    if plr:isValid() then
        ba.print(plr)
        local player_dir = plr.Orientation:getFvec():getNormalized()
        local offset = plr.Position + plr.Orientation:unrotateVector(plr.Class.Model.Eyepoints[1].Position)
        local screenX, screenY = (offset + player_dir):getScreenCoords()
        -- get the player's current velocity vector
        local velocity = (plr.Physics.Velocity + offset)
        local vel_screen_x, vel_screen_y = velocity:getScreenCoords()
        if screenX ~= false and vel_screen_x ~= false then
            local r,g,b,a = hu.getHUDGaugeColorInMission(0)
            local cacheR, cacheG, cacheB, cacheA = gr.getColor()
            gr.setColor(0,255,0)
            gr.drawLine(vel_screen_x, vel_screen_y, screenX, screenY)
            gr.setColor(cacheR,cacheG,cacheB,cacheA)
        end
    end
end