Whenever I change my particle system values from the script during runtime the particle system starts from scratch but I don’t want it to restart I want it to continue from where its values are changed.
You cannot modify the “System” and expect it to affect the “[Particles][1]” which have already been emitted. Instead you need to [get][2] and [set][3] each particle individually in a loop:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveParticle : MonoBehaviour
{
public ParticleSystem _ps;
ParticleSystem.MainModule _ps_main;
ParticleSystem.Particle[] _p;
public float _speed = 5f;
int numParticlesAlive;
void Awake()
{
_ps = this.GetComponent<ParticleSystem>();
_ps_main = _ps.main;
_p = new ParticleSystem.Particle[_ps_main.maxParticles];
}
public void StartParticle()
{
numParticlesAlive = _ps.GetParticles(_p);
for (int i = 0; i < numParticlesAlive; i++)
{
_p*.velocity = new Vector3(0f, 0f, _speed);*
-
}*
-
_ps.SetParticles(_p, numParticlesAlive);*
}
public void ResetParticle()
{
_ps.Stop();
_ps.Play();
}
}
[1]: Unity - Scripting API: Particle
[2]: Unity - Scripting API: ParticleSystem.GetParticles
[3]: Unity - Scripting API: ParticleSystem.SetParticles