I have a script that is suppose to display test on the screen and play an animation when the player walks through a box collider only it doesn’t work. When the player walks through the collider nothing is played. I have several other scripts that are almost identical to this and they all work perfectly so I don’t understand the problem.
This is the script…
using UnityEngine;
using System.Collections;
public class LightScene3 : MonoBehaviour {
public int wait;
public GUIStyle text;
string message = " ";
//GUI Box
void OnGUI() {
GUI.Label((new Rect(600,400,200,200)),message ,text);
}
//Displaying text
IEnumerator OnTriggerEnter(Collider otherObjective){
if (otherObjective.tag == "Player") {
message = "Insert Text Here";
GetComponent<UnityEngine.Animation> ().Play ("TeacherMonster");
yield return new WaitForSeconds(wait);
message = "Insert More Text Here";
yield return new WaitForSeconds(wait);
}
}
}