I'm trying to turn a game object on and off when the player passes through a trigger, with no success yet.
This seems like it should be simple, not sure why it's not working. The object in question is 3dText, but it is under a parent called ROTH_PLACARD. I have a trigger tagged as ROTH_INFO to trigger the object on.
function OnTriggerEnter(hit : Collider)
{
var ROTH_PLACARD : GameObject = GameObject.Find("ROTH_PLACARD");
if (hit.gameObject.tag == "ROTH_INFO" )
{
ROTH_PLACARD.active = true;
}
}
There is so much different information out there on turning objects on and off, and yet I haven't gotten one thing to work yet.
The script itself looks relatively fine according to the information given
My advice would be to add a Debug.Log message after each line, so you can see the flow of the code. Also, print out if ROTH_PLACARD is null, and what the hit tag was
That checks if the OTHER object that touched the trigger has the "ROTH_INFO" tag, and I'm not sure if that's what you want (your explanation was a little fuzzy). Whatever script this is, it's going to get the tag of the OTHER game object. If you want to check THIS game object's tag, just use `gameObject.tag`.
Other than that, the script looks fine, assuming everything's set up correctly, and your collider is set to be a Trigger. I would do as Mike said, by adding Debug statements to see which lines are being executed or not.