/// <summary>
 /// 设置位于曲线的位置
 /// </summary>
 /// <param name="trans"></param>
 /// <param name="distanceAlongPath"></param>
 void SetCartPosition(Transform trans, CinemachineSmoothPath path, float distanceAlongPath)
 {
     if (path != null)
     {
         float m_Position;
         m_Position     = path.StandardizeUnit(distanceAlongPath, m_PositionUnits);
         trans.position = path.EvaluatePositionAtUnit(m_Position, m_PositionUnits);
         trans.rotation = path.EvaluateOrientationAtUnit(m_Position, m_PositionUnits);
     }
 }
Exemplo n.º 2
0
    void SetCartPosition(float distanceAlongPath)
    {
        if (m_Path != null)
        {
            m_Position = m_Path.StandardizeUnit(distanceAlongPath, m_PositionUnits);
            Vector3 pos = m_Path.EvaluatePositionAtUnit(m_Position, m_PositionUnits);
            transform.position = new Vector3(pos.x, pos.y, pos.z);

            //transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, m_Path.EvaluateOrientationAtUnit(m_Position, m_PositionUnits).eulerAngles.y, transform.rotation.eulerAngles.z);
            transform.rotation = m_Path.EvaluateOrientationAtUnit(m_Position, m_PositionUnits);
        }
    }