Пример #1
0
 void SetCartPosition(float distanceAlongPath)
 {
     if (m_Path != null)
     {
         m_Position         = m_Path.StandardizeUnit(distanceAlongPath, m_PositionUnits);
         transform.position = m_Path.EvaluatePositionAtUnit(m_Position, m_PositionUnits);
         var tangent = m_Path.EvaluateTangentAtUnit(m_Position, m_PositionUnits);
         tangent.y          = 0; // Y方向を無効
         transform.rotation = Quaternion.LookRotation(tangent);
     }
 }
Пример #2
0
    void UpdateSpeed()
    {
        if (m_Path != null)
        {
            float   m_UnitPosition = m_Path.StandardizeUnit(m_Position, m_PositionUnits);
            Vector3 t = m_Path.EvaluateTangentAtUnit(m_Position, m_PositionUnits);

            m_Speed += (m_G * t.normalized.y - m_DragCoefficient * m_AirDensity * Mathf.Sqrt(m_Speed) + manualAcceleration) * Time.deltaTime;
            m_Speed  = Mathf.Clamp(m_Speed, m_MinSpeed, m_MaxSpeed);

            Debug.Log(m_G * t.normalized.y + "   " + (m_DragCoefficient * m_AirDensity) + "   " + manualAcceleration);
        }
    }
Пример #3
0
    // Update is called once per frame
    protected override void Update()
    {
        base.Update();

        if (!path)
        {
            return;
        }
        _pathTangent = path.EvaluateTangentAtUnit(pathPosition, _units);

        if (master)
        {
            MasterUpdate();
        }

        UpdatePosition();
    }