Hello,
I have some code written in C#, which starts and stops a particle system when entering a trigger. What I have an issue is finding a gameobject in code with C# to disable it’s mesh renderer. I know how to do this in Javascript. Can anyone point out in my “OnTriggerExit” what should be the correct syntax.
using UnityEngine;
using System.Collections;
public class Mine_Explode : MonoBehaviour
{
public AudioClip Hurt;
private GameObject Mine;
void Start ()
{
particleSystem.Stop();
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Weapon")
{
particleSystem.Play();
audio.PlayOneShot(Hurt);
}
}
void OnTriggerExit(Collider other)
{
if (other.tag == "Weapon")
{
Destroy(particleSystem);
Mine = GameObject.Find("Gas canister");
Mine.GetComponent<MeshRenderer>.enabled = false;
}
}
}
Cheers!