/// <summary> /// Calculates the point each animation curve point. /// </summary> private void CalculatePoint(float _point, int _loopNumber, BaseSpline.SplineIterator _iterator, SplineParticles _target, float _offset) { _iterator.SetOffsetPercent(_point); //Calc modifiers float lifeTimeModifier = _target.GetComponent<ParticleSystem>().startLifetime; float loopsModifier = _target.loopNumber; Vector3 currentPosition = _target.transform.TransformPoint(_iterator.GetPosition()); Vector3 tangentAtPoint = (_iterator.GetTangent().normalized); Vector3 velocityAtPoint = Vector3.zero; if (_point == 0 && _target.Spline.WrapMode == BaseSpline.SplineWrapMode.Loop) { _iterator.SetOffsetPercent(1-_target.pathQuality); previousPoint = _target.transform.TransformPoint(_iterator.GetPosition()); } else if (_point == 0 && _target.Spline.WrapMode != BaseSpline.SplineWrapMode.Loop) { _iterator.SetOffsetPercent(_point+_target.pathQuality); previousPoint = _target.transform.TransformPoint(_iterator.GetPosition()); } velocityAtPoint = (currentPosition - previousPoint).magnitude * tangentAtPoint; previousPoint = currentPosition; velocityAtPoint *= loopsModifier*(1/_target.pathQuality)/lifeTimeModifier; _target.velocityCurveX.AddKey(_point/_loopNumber + _offset,velocityAtPoint.x); _target.velocityCurveY.AddKey(_point/_loopNumber + _offset,velocityAtPoint.y); _target.velocityCurveZ.AddKey(_point/_loopNumber + _offset,velocityAtPoint.z); }