Exemple #1
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);
        }
    }
Exemple #2
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);
     }
 }
Exemple #3
0
    void SetCartPosition(float distanceAlongPath)
    {
        if (m_Path != null)
        {
            m_Position = m_Path.StandardizeUnit(distanceAlongPath, m_PositionUnits);

            var newPos = m_Path.EvaluatePositionAtUnit(m_Position, m_PositionUnits);
            var dir    = newPos - transform.position;

            transform.position = m_Path.EvaluatePositionAtUnit(m_Position, m_PositionUnits);
            if (dir != Vector3.zero)
            {
                transform.transform.rotation = Quaternion.LookRotation(dir);
            }
        }
    }