Exemple #1
0
    void SetPos(float pos)
    {
        switch (trainType)
        {
        case TrainType.Clamp:
            break;

        case TrainType.Loop:
            pos = Mathf.Repeat(pos, distance ? spline.totalLength : 1);
            break;

        case TrainType.PingPong:
            pos = Mathf.PingPong(pos, distance ? spline.totalLength : 1);
            break;
        }
        if (distance)
        {
            transform.position = spline.GetPoint(pos);
            transform.rotation = spline.GetOrientation(pos);
        }
        else
        {
            transform.position = spline.GetPoint(spline.DistanceToTime(pos));
            transform.rotation = spline.GetOrientation(spline.DistanceToTime(pos));
        }
    }
 private void VisualizeOrientations()
 {
     for (float dist = 0f; dist < spline.totalLength; dist += 1)
     {
         Vector3    point = spline.GetPoint(dist);
         Quaternion rot   = spline.GetOrientationFast(dist);
         Vector3    up    = rot * Vector3.up;
         Handles.color = Color.white;
         Handles.DrawLine(point, point + up);
         Handles.color = Handles.zAxisColor;
         Vector3 forward = rot * Vector3.forward;
         Handles.DrawLine(point, point + forward);
     }
 }