- Home /
Trigger fires, but the code doesn't execute.
private var guiTextObject : GameObject;
private static var textOn : boolean = false;
private static var triggerID : String = "";
private static var messageToDisplay : String= "Message Text";
private static var titleToDisplay : String= "Message Text";
//static var InfoboxSkin : GUISkin;
//static var MyCustomGuiStyle : GUIStyle;
//static var MyCustomGuiStyleTitle : GUIStyle;
function OnTriggerEnter (other:Collider){
textOn = true;
triggerID = gameObject.name;
//name.CSGui.padding.left = 0
//print ("Test"+triggerID);
switch(triggerID)
{
case "Trigger-Building1_Info":
titleToDisplay = "Building1";
messageToDisplay = "flavor text";
break;
case "Trigger-Building2_Info":
titleToDisplay = "Building2";
messageToDisplay = "more flavor text";
break;
}
}
function OnTriggerExit (other:Collider)
{
textOn = false;
}
public static function ToggleText()
{
if (textOn)
{
textOn = false;
}
else
{
textOn = true;
}
}
public static function TextOn() : boolean
{
return textOn;
}
public static function GetMessage() : String
{
return messageToDisplay;
}
public static function GetTitle() : String
{
return titleToDisplay;
}
Here's a little piece of my code. Basically the player can walk into these triggers and a GUI pops up with some text explaining the area.
Now for my problem, It works fine in all of my scenes except for 4 I've added recently. I added a print("this trigger works") to see if it was firing at all, and it showed up, but it's just not executing the code. In fact none of the triggers I had in previous scenes work in these new ones.
What could be the cause?
I appreciate any help! Thanks!
Comment
Your answer
Follow this Question
Related Questions
"GetQualityLevel" is not a member of "QualitySettings" 2 Answers
issues with collision detection 1 Answer
colliders not working 0 Answers
Can't get bullet to spawn and move 1 Answer