Hey so I’m building a baseball game and I’m using OnTriggerEnter to detect whether or not the baseball enters the strike zone. The strike zone is big enough so it can be detected and the ball isn’t moving too fast. I want to display ("STRIKE!) once it hits the trigger, but nothing is happening. pls help
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Strike : MonoBehaviour {
public AudioSource src;
public ParticleSystem stars;
public Text StrikeText;
private void Start()
{
StrikeText.text = " ";
}
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "ball")
{
src.Play();
Instantiate(stars, transform.position, transform.rotation);
StrikeText.text = "STRIKE!";
Destroy(other.gameObject);
SecondsWait();
StrikeText.text = " ";
}
}
IEnumerator SecondsWait()
{
yield return new WaitForSeconds(4);
}
}