Esempio n. 1
0
        internal static void DrawPathGizmos(CinemachinePath path, GizmoType selectionType)
        {
            // Draw the path
            Color colorOld = Gizmos.color;

            Gizmos.color = (Selection.activeGameObject == path.gameObject)
                ? path.m_Appearance.pathColor : path.m_Appearance.inactivePathColor;
            float   step    = 1f / path.m_Appearance.steps;
            Vector3 lastPos = path.EvaluatePosition(path.MinPos);
            Vector3 lastW   = (path.EvaluateOrientation(path.MinPos)
                               * Vector3.right) * path.m_Appearance.width / 2;

            for (float t = path.MinPos + step; t <= path.MaxPos + step / 2; t += step)
            {
                Vector3 p  = path.EvaluatePosition(t);
                Vector3 w  = (path.EvaluateOrientation(t) * Vector3.right) * path.m_Appearance.width / 2;
                Vector3 w2 = w * 1.2f;
                Vector3 p0 = p - w2;
                Vector3 p1 = p + w2;
                Gizmos.DrawLine(p0, p1);
                Gizmos.DrawLine(lastPos - lastW, p - w);
                Gizmos.DrawLine(lastPos + lastW, p + w);
                lastPos = p;
                lastW   = w;
            }
            Gizmos.color = colorOld;
        }
    void SetCartPosition(float distanceAlongPath)
    {
        if (m_Path == null)
        {
            return;
        }

        m_CurrentDistance = m_Path.NormalizePathDistance(distanceAlongPath);
        float pathPos = m_Path.GetPathPositionFromDistance(m_CurrentDistance);

        transform.position = m_Path.EvaluatePosition(pathPos);
        transform.rotation = m_Path.EvaluateOrientation(pathPos);
    }
Esempio n. 3
0
        internal static void DrawPathGizmos(CinemachinePath path, GizmoType selectionType)
        {
            // Draw the path
            Color colorOld = Gizmos.color;

            Gizmos.color = (Selection.activeGameObject == path.gameObject)
                ? path.m_Appearance.pathColor : path.m_Appearance.inactivePathColor;
            float   step    = 1f / path.m_Resolution;
            Vector3 lastPos = path.EvaluatePosition(path.MinPos);
            Vector3 lastW   = (path.EvaluateOrientation(path.MinPos)
                               * Vector3.right) * path.m_Appearance.width / 2;

            for (float t = path.MinPos + step; t <= path.MaxPos + step / 2; t += step)
            {
                Vector3    p  = path.EvaluatePosition(t);
                Quaternion q  = path.EvaluateOrientation(t);
                Vector3    w  = (q * Vector3.right) * path.m_Appearance.width / 2;
                Vector3    w2 = w * 1.2f;
                Vector3    p0 = p - w2;
                Vector3    p1 = p + w2;
                Gizmos.DrawLine(p0, p1);
                Gizmos.DrawLine(lastPos - lastW, p - w);
                Gizmos.DrawLine(lastPos + lastW, p + w);
#if false
                // Show the normals, for debugging
                Gizmos.color = Color.red;
                Vector3 y = (q * Vector3.up) * path.m_Appearance.width / 2;
                Gizmos.DrawLine(p, p + y);
                Gizmos.color = (Selection.activeGameObject == path.gameObject)
                    ? path.m_Appearance.pathColor : path.m_Appearance.inactivePathColor;
#endif
                lastPos = p;
                lastW   = w;
            }
            Gizmos.color = colorOld;
        }