I have a simple project. When you enter a trigger, if the textfield contains a specific word, you would move to the next scene. And its not working even know I am not getting any errors
private var inTrigger = false;
var stringToEdit : String = "";
function OnTriggerEnter(other: Collider)
{
if (other.CompareTag("Player"))
{
inTrigger = true;
}
}
function OnGUI()
{
stringToEdit = GUI.TextField (Rect (10, 10, 200, 20), stringToEdit, 23);
if (inTrigger == true)
{
if (stringToEdit == "times")
{
Application.LoadLevel("Scene2");
}
}
}
function OnTriggerExit(other: Collider)
{
if (other.CompareTag("Player")
{
inTrigger = false;
}
}
What error is it failing with?
– cmpgk10241.) Please format your code correctly. 2.) It's JAVASCRIPT, not Java - they're completely different languages. 3.) "it don't work" - so what does happen? Does inTrigger get set to true when you enter the trigger as you expect? Does stringToEdit get set to the value you expect? Put some Debug.Log statements in there to see what's going on.
– tanoshimiIt wont load scene2 or give any indication that any thing about it working
– luxidiumI get an error that says "The referenced script on this Behaviour is missing"
– luxidiumI fixed the error and it still will not work its not switching to scene2
– luxidium