I have one question. I want the Particles I created with Particle System to go from one point to another and I want it to do it at a certain speed. But it either doesn’t move to the position I gave it at all or it goes very fast, it seems like it’s teleporting. How can i fix it?
public class PartCollecter : MonoBehaviour
{
public ParticleSystem ps;
List<ParticleSystem.Particle> Parts = new List<ParticleSystem.Particle>();
public GameObject TargetObj;
ParticleSystem m_System;
ParticleSystem.Particle[] m_Particles;
public float m_SmoothTime = 0.5f;
public float m_Speed = 10;
Vector3 m_Velocity;
// Start is called before the first frame update
void Start()
{
Invoke("Move", 2f);
}
private void Update()
{
}
public void Move()
{
if (m_System == null)
m_System = GetComponent<ParticleSystem>();
if (m_Particles == null || m_Particles.Length < m_System.main.maxParticles)
m_Particles = new ParticleSystem.Particle[m_System.main.maxParticles];
int numParticlesAlive = m_System.GetParticles(m_Particles);
for (int i = 0; i < numParticlesAlive; i++)
{
m_Particles[i].position = Vector3.SmoothDamp(transform.position, TargetObj.transform.position, ref m_Velocity, m_SmoothTime, m_Speed * Time.deltaTime);
}
m_System.SetParticles(m_Particles, numParticlesAlive);
}
}