How do I hide/show an object, when the player enters a trigger zone?

The guests: “Player, MeshTrigger and HiddenObject”

So the mesh trigger is working. It logs in the console when the player moves through it. (Code below!) But… how can I now make it so that when the player enters/leaves the MeshTrigger collider, an object will appear/disappear?

If it helps, the object is to be an in game “UI element” with their own trigger events.

using UnityEngine;
using System.Collections;

public class worldTrigger : MonoBehaviour {
	void OnTriggerEnter (Collider other) {
		if (other.CompareTag ("Player")) {
			Debug.Log ("Player Has Entered");
		}
	}
	void OnTriggerStay (Collider other) {
		if (other.CompareTag ("Player")) {
			Debug.Log ("...");
		}
	}
	void OnTriggerExit (Collider other) {
		if (other.CompareTag ("Player")) {
			Debug.Log ("Player Has Exited");
		}
	}
}

Got it from here:

I’m sorry and thanks. :slight_smile:
I’m very new to C#. Please be mean so I can learn.

lol nvm. Figured it out.
So I named the hidden object hidey.

edit:
instead of gameObject.GetComponent().enabled = false;, use gameObject.SetActive(false); to hide everything!!!

using UnityEngine;
using System.Collections;

public class worldTrigger : MonoBehaviour {

	private GameObject hidey;
	void Start() {
		hidey = GameObject.Find("hidey");
		hidey.gameObject.SetActive(false);
	}

	void OnTriggerEnter (Collider other) {
		if (other.CompareTag ("Player")) {
			hidey.gameObject.SetActive(true);
		}
	}

	void OnTriggerExit (Collider other) {
		if (other.CompareTag ("Player")) {
			hidey.gameObject.SetActive(false);
		}
	}
}

put this script inside what?

may u explain what u did ?