Hi,
I’ve got a JavaScript and I’m trying to make a specific object (being a GUITexture) be deleted once the Player passes a certain point, which is marked by another object. The JavaScript inside this object is:
function OnTriggerEnter (myTrigger : Collider) {
if(myTrigger.gameObject.name == "player"){
Destroy (gameObject);
}
}
With intentions to destroy the ‘GUIText’ component when it is triggered by the player. Unfortunately, when testing this, the only object that was deleted was the trigger itself, and I’m not sure how to change this to make it so the ‘GUIText’ can be deleted on the trigger.
The GUIText should be loaded with the level, but destroyed when a different object is triggered by the player. I’m still learning JavaScript, so if anyone could help me it would be amazing. Thanks much.