コード例 #1
0
        /// <summary>
        /// Sets the curve points.
        /// </summary>
        private void SetCurvePoints(int _loopNumber, BaseSpline.SplineIterator _iterator, SplineParticles _target, float _offset)
        {
            previousPoint = Vector3.zero;

            for (float i = 0; i <= 1; i += _target.pathQuality)
            {
                CalculatePoint(i, _loopNumber, _iterator, _target, _offset);
            }
        }
コード例 #2
0
	void Start () {
		
		//Cache variables
		if (particlePath != null)
		{
			myTransform = transform;
			
			splineIterator = particlePath.Spline.GetIterator();
			splineTansform = particlePath.transform;
			myParticleSystem = GetComponent<ParticleSystem>();
		}
		else
			Debug.LogWarning("You have to set a path to follow");
	}
コード例 #3
0
        void Start()
        {
            //Cache variables
            if (particlePath != null)
            {
                myTransform = transform;

                splineIterator   = particlePath.Spline.GetIterator();
                splineTansform   = particlePath.transform;
                myParticleSystem = GetComponent <ParticleSystem>();
            }
            else
            {
                Debug.LogWarning("You have to set a path to follow");
            }
        }
コード例 #4
0
ファイル: RuntimeSplineController.cs プロジェクト: huxii/OLU
        void Awake()
        {
            BezierSplineComponent splineComponent = GetComponent <BezierSplineComponent>();

            if (splineComponent == null)
            {
                Debug.LogError("[ERROR] You have to add a BezerierSplineComponent to this GameObject. Disabling...");
                gameObject.SetActive(false);
                return;
            }
            else
            {
                spline   = splineComponent.Spline;
                iterator = spline.GetIterator();
                UpdatePointArray();
            }
        }
コード例 #5
0
		void Awake()
		{
			BezierSplineComponent splineComponent = GetComponent<BezierSplineComponent>();

			if (splineComponent == null)
			{
				Debug.LogError("[ERROR] You have to add a BezerierSplineComponent to this GameObject. Disabling...");
				gameObject.SetActive(false);
				return;
			}
			else
			{
				spline = splineComponent.Spline;
				iterator = spline.GetIterator();
				UpdatePointArray();
			}
		}
コード例 #6
0
        /// <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);
        }