Update Just Once

I can’t figure out this, I know it’s been answered around a lot, but trying to figure out if an object is alive or not (exists in the scene or not) in order to activate another object if so, I did this. Obviously it works, the only problem is it keeps working :slight_smile:

function Update () {
   if (GameObject.Find (ObjectiveName) != null) {
   		
   		Debug.Log("STILL HERE");	
         
         } else {
			Debug.Log("DEAD");
			messageObject.gameObject.SetActive(true);
			messageText.text = myString;
         }
}

What you could do is add a boolean to check for as well to make sure that it is only done once.
Here is how I might do it:

private var doOnce:boolean = true; 
function Update () {
    if (GameObject.Find (ObjectiveName) != null) {
            doOnce = true;      
    } else {
         if(doOnce == true){
                doOnce = false;
                messageObject.gameObject.SetActive(true);
                messageText.text = myString;
         }
    }
 }

It looks as if it should work, maybe use a bool to explicitely control the condition

if (!IsThisThingAlreadyAssigned)
{
ObjectiveTHing = GameObject.Find (ObjectiveName);
IsThisThingAlreadyAssigned = true;

}

this.enabled = false;