I’m trying to set the seed of a particle system so every time it’s run, the particles move in the same pattern.
I’ve attached what I’m using below. What am I doing wrong?
using UnityEngine;
using System.Collections;
public class ParticleRandomTester : MonoBehaviour {
uint m_seed = 42;
ParticleSystem m_ps;
[SerializeField]
bool m_restart;
void Awake()
{
m_ps = gameObject.GetComponent<ParticleSystem>();
}
void Update()
{
if (m_restart)
{
m_restart = false;
Restart();
}
}
void Restart()
{
m_ps.Clear();
m_ps.Stop();
m_ps.randomSeed = m_seed;
Debug.Log("Setting seed: " + m_seed);
m_ps.time = 0;
m_ps.Play();
}
}
I've simplified this even further and still it runs differently every time. using UnityEngine; using System.Collections; public class ParticleRandomTester : MonoBehaviour { void Awake() { var ps = gameObject.GetComponent<ParticleSystem>(); ps.randomSeed = 42; } }
– benhumphreys