コード例 #1
0
        public static void GizmosDrawLineInterpolated(LineBase source, LineRendererBase renderer)
        {
            Vector3 firstPos = source.GetPoint(0f);
            Vector3 lastPos  = firstPos;
            Color   gColor   = renderer.GetColor(0);

            gColor.a     = 0.5f;
            Gizmos.color = gColor;
            Gizmos.DrawSphere(firstPos, renderer.GetWidth(0) / 2);
            for (int i = 1; i <= renderer.NumLineSteps; i++)
            {
                float   normalizedLength = (1f / (renderer.NumLineSteps)) * i;
                Vector3 currentPos       = source.GetPoint(normalizedLength);
                gColor       = renderer.GetColor(normalizedLength);
                gColor.a     = gColor.a * 0.5f;
                Gizmos.color = gColor;
                Gizmos.DrawLine(lastPos, currentPos);
                Gizmos.DrawSphere(currentPos, renderer.GetWidth(normalizedLength) / 2);
                lastPos = currentPos;
            }

            if (source.Loops)
            {
                Gizmos.DrawLine(lastPos, firstPos);
            }
        }
コード例 #2
0
        public void UpdateCollection()
        {
            if (Source == null)
            {
                return;
            }

            if (prevPoints == null || prevPoints.Length != Objects.Count)
            {
                prevPoints = new Vector3[Objects.Count];
            }

            randomPosition = new System.Random(Seed);
            Vector3    linePoint    = source.GetPoint(NormalizedDistance);
            Quaternion lineRotation = source.GetRotation(NormalizedDistance, RotationTypeOverride);

            for (int i = 0; i < Objects.Count; i++)
            {
                if (Objects[i] == null)
                {
                    continue;
                }

                Vector3 point = source.transform.TransformVector(GetRandomPoint());
                point.x = (float)(point.x + (noise.Evaluate((point.x + AxisOffset.x) * ScaleMultiplier, Time.unscaledTime * AxisSpeed.x * SpeedMultiplier)) * AxisStrength.x * StrengthMultiplier);
                point.y = (float)(point.y + (noise.Evaluate((point.y + AxisOffset.y) * ScaleMultiplier, Time.unscaledTime * AxisSpeed.y * SpeedMultiplier)) * AxisStrength.y * StrengthMultiplier);
                point.z = (float)(point.z + (noise.Evaluate((point.z + AxisOffset.z) * ScaleMultiplier, Time.unscaledTime * AxisSpeed.z * SpeedMultiplier)) * AxisStrength.z * StrengthMultiplier);

                Objects[i].position = point + linePoint;
                if (SwarmVelocities)
                {
                    Vector3 velocity = prevPoints[i] - point;
                    Objects[i].rotation = Quaternion.Lerp(lineRotation, Quaternion.LookRotation(velocity, Vector3.up), VelocityBlend);
                }
                else
                {
                    Objects[i].rotation = lineRotation;
                }
                Objects[i].Rotate(RotationOffset);

                prevPoints[i] = point;
            }
        }
コード例 #3
0
        private void Update()
        {
            Vector3 linePoint = source.GetPoint(NormalizedDistance);

            Object.position = linePoint;
        }