I’m goiing utterly potty here.
I’m now working through the Unity tutorial and using the script they’ve used in the tutorial
Here is my code which is very similar. Everything works apart from the particle system not working!
public SpriteRenderer toggleRain;
public SpriteRenderer rainOff;
public ParticleSystem ps;
public rainLauncher dorain;
// public AudioClip rain;
void Awake()
{
rainOff = GameObject.Find("sunCloud").GetComponent<SpriteRenderer>();
toggleRain = GameObject.Find("rainCloud").GetComponent<SpriteRenderer>();
toggleRain.enabled = false;
}
void Start()
{
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Vector3 pos = Input.mousePosition;
Collider2D hitcollider = Physics2D.OverlapPoint(Camera.main.ScreenToWorldPoint(pos));
if (hitcollider != null && (hitcollider.CompareTag("cloud")))
{
if (!toggleRain.enabled)
{
toggleRain.enabled = true;
rainOff.enabled = false;
GetComponent<AudioSource>().Play();
Debug.Log("raining");
ps.Emit(0);
}
else
{
toggleRain.enabled = false;
rainOff.enabled = true;
GetComponent<AudioSource>().Pause();
Debug.Log("not raining");
}
}
}
}
}