Ejemplo n.º 1
0
    //Move look ahead point
    void UpdateLookAheadPoint()
    {
        m_rawLookAheadPoint = GlobalScript.PredictPointInDirection(transform.position, m_direction, lookAheadDistance);

        if (!m_waypointIsStrict)
        {
            if (GlobalScript.GetTwoLinesIntersection(transform.position, m_rawLookAheadPoint, m_prevWaypoint, m_currentWaypoint, ref m_intersectionPoint))
            {
                m_overflowAmount = lookAheadDistance - GlobalScript.GetDistance(transform.position, m_intersectionPoint);
                if (m_overflowAmount > 0)
                {
                    if (GlobalScript.GetDistance(m_intersectionPoint, m_currentWaypoint) < m_wpDistance)
                    {
                        m_overflowAmount = Mathf.Min(m_overflowAmount, m_speed * lookAheadDistance / 10);
                        m_lookAheadPoint = m_intersectionPoint + m_crossWpDirection * m_overflowAmount;
                        return;
                    }
                }
            }
            m_lookAheadPoint = transform.position + GlobalScript.GetDirection(transform.position, m_currentWaypoint) * lookAheadDistance;
        }
    }