获取两个向量中间位置的点

    /// 
    /// 获取两点之间距离一定百分比的一个点
    /// 
    /// 起始点
    /// 结束点
    /// 起始点到目标点距离百分比
    /// 
    private Vector3 GetBetweenPoint(Vector3 start, Vector3 end, float percent)
    {
        Vector3 normal = (end - start).normalized;
        float distance = Vector3.Distance(start, end);
        return normal * (distance * percent) + start;
    }

    /// 
    /// 获取两点之间一定距离的点
    /// 
    /// 起始点
    /// 结束点
    /// 距离
    /// 
    private Vector3 GetBetweenPoint(Vector3 start, Vector3 end, float distance)
    {
        Vector3 normal = (end - start).normalized;
        return normal * distance + start;
    }

参考链接: http://blog.gamerisker.com/archives/496.html

你可能感兴趣的:(Unity)