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