Beispiel #1
0
    void Rotate()
    {
        if (m_waypointIsStrict)
        {
            m_desiredDirection = GlobalScript.GetDirection(transform.position, m_currentWaypoint);
        }
        else
        {
            m_desiredDirection = GlobalScript.GetDirection(transform.position, m_lookAheadPoint);
        }

//hardcoded prototype
//		m_angle = (GlobalScript.GetAngle(m_rvoDir,m_desiredDirection) - 90)/180;
//		m_angle = Mathf.Clamp01 (m_angle);
//		m_angle = 1f;
        m_rvoWeight = Mathf.Clamp01(m_rvoDisp / m_maxSpeed) / 2f;       // * m_angle;
        m_direction = (m_rvoWeight * m_rvoDir + (1 - m_rvoWeight) * m_direction).normalized;

        if (!m_isMoving)
        {
            if (GlobalScript.GetAngle(m_desiredDirection, m_direction) < m_maxAngularRotationSpeed)
            {
                m_isMoving = true;
            }
        }


        if (GlobalScript.GetAngle(m_desiredDirection, m_direction) > 1f)
        {
            m_direction = Vector3.Slerp(m_direction, m_desiredDirection, m_maxAngularRotationSpeed / (GlobalScript.GetAngle(m_direction, m_desiredDirection)));
        }
        transform.rotation = Quaternion.LookRotation(m_direction);
    }
Beispiel #2
0
    void AdjustSpeed()
    {
        if (m_dynamicSpeedChange)
        {
            m_speed = m_maxSpeed * (1f - m_decelerationInfluenceFraction * m_angleToDecelerationRatio *
                                    Mathf.Clamp(GlobalScript.GetAngle(m_desiredDirection, m_direction), 0f, 180f));

            if (m_waypointIsStrict && m_wpDistance < m_strictWpApproachingRange)
            {
                m_speed *= m_wpDistance / m_strictWpApproachingRange;
            }

            if (m_rvoScript && !float.IsNaN(m_rvoSpeedComp))
            {
                m_speed *= m_rvoSpeedComp;
            }
        }
    }