I cannot control particle systems via script.

below is my code: It does nothing. I cannot find any way to enable and disable emission through code. The Play(), Pause(), and Stop() functions of the particle system class are also not doing anything. My particle system is assigned through the inspector. What am I missing? Thanks for the help.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Activate : MonoBehaviour
{
public ParticleSystem Particles;

void start()
{
	Particles.emission.enabled = false;
}

void OnTriggerEnter (Collider other)
{
	if(other.CompareTag("Player"))
	{
		Particles.emission.enabled = true;
	}
}

void OnTriggerExit (Collider other)
{
	if(other.CompareTag("Player"))
	{	
		Particles.emission.enabled = false;
	}
}

}

When you want to disable a particle system via script then you are doing it wrong.
Use this instead.

In you case you can do it something like this.

private ParticleSystem ps;
public bool moduleEnabled; 

void start()
 {
     ps = GetComponent<ParticleSystem>();
    
 }

void Update(){
   var emission = ps.emission;
   emission.enabled = moduleEnabled;
}
 void OnTriggerEnter (Collider other)
 {
     if(other.CompareTag("Player"))
     {
         moduleEnabled = true;
     }
 }
 void OnTriggerExit (Collider other)
 {
     if(other.CompareTag("Player"))
     {    
         moduleEnabled = false;
     }
 }

Note: This code is not tested yet so please test it out first :slight_smile:
Hope it helps :slight_smile: