void LateUpdate() { if (_particle_array == null) { Start(); } if (isRectangleSizeUpdating) { Calculate_The_Four_Corners(); } _numParticles = _particle_system.GetParticles(_particle_array); if (_numParticles > 0) { for (int i = 0; i < _numParticles; i++) { ParticleSystem.Particle obj = _particle_array[i]; // This made it based on the particle lifetime // float normalizedLifetime = (1.0f - obj.remainingLifetime / obj.startLifetime); // // if(hasRandomStartingPoints){ // normalizedLifetime += Get_Value_From_Random_Seed_0t1(obj.randomSeed, 100.0f); // normalizedLifetime = normalizedLifetime % 1.0f; // } // // Path_Point axis = _path.GetPathPoint(_path.TotalDistance * normalizedLifetime, isSmooth); // This made it based on the paritcle speed float dist = (obj.startLifetime - obj.remainingLifetime) * obj.velocity.magnitude; if (hasRandomStartingPoints) { dist += Get_Value_From_Random_Seed_0t1(obj.randomSeed, 100.0f) * _path.TotalDistance; } dist = dist % _path.TotalDistance; Path_Point axis = _path.GetPathPoint(dist, isSmooth); Vector2 offset = Vector2.zero; if (pathWidth > 0) { offset = Math_Functions.AngleToVector2D(obj.randomSeed % 360.0f); offset *= Get_Value_From_Random_Seed_0t1(obj.randomSeed, 150.0f) * pathWidth; } _particle_array[i].position = axis.point + (isFlat ? Vector3.zero : axis.right * offset.x) + (axis.up * offset.y); _particle_array[i].velocity = axis.forward * _particle_array[i].velocity.magnitude; } _particle_system.SetParticles(_particle_array, _numParticles); } }
void LateUpdate() { if (_particle_array == null) { Start(); _path_comp.Update_Path(); } else if (isPathUpdating) { _path_comp.Update_Path(); } _numParticles = _particle_system.GetParticles(_particle_array); if (_numParticles > 0) { for (int i = 0; i < _numParticles; i++) { ParticleSystem.Particle obj = _particle_array[i]; Path_Point axis = _path_comp.GetPathPoint(_path_comp.TotalDistance * (1.0f - obj.remainingLifetime / obj.startLifetime)); Vector2 offset = Math_Functions.AngleToVector2D(obj.randomSeed % 360.0f); offset *= (((float)obj.randomSeed % 100.0f) / 100.0f) * pathWidth; _particle_array[i].position = axis.point + (axis.right * offset.x) + (axis.up * offset.y); _particle_array[i].velocity = axis.forward * _particle_array[i].velocity.magnitude; } _particle_system.SetParticles(_particle_array, _numParticles); } }