Question by
replay55 · Dec 11, 2015 at 05:57 PM ·
colliderontriggerenter
OnTriggerEnter playing without tagged object triggering
I'm writing out a script, so that when the player enters an area a particle system is enabled, and text is shown at the bottom the screen. The code for this is as follows:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class midgetscript : MonoBehaviour {
public Text midgettext;
// Use this for initialization
void Start () {
GetComponent<ParticleSystem> ().Stop ();
midgettext.enabled = false;
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider col){
if (col.gameObject.tag == "Player")
{
GetComponent<ParticleSystem> ().Play ();
midgettext.enabled = true;
}
}
}
However, the particle system, as well as the text, play on Start, even though the script is supposed to disable them on start? Is there anything I'm doing wrong? What can I do to make this work?
Comment
Have it tried in Awake()? Or maybe you disable it directly from the component by untick play on start or something that semiliar
Your answer
![](https://koobas.hobune.stream/wayback/20220612052232im_/https://answers.unity.com/themes/thub/images/avi.jpg)