- Home /
Turn Mesh Renderer on separate object?
Hello,
I'm trying to turn my HUD back on(or off) when the player hits a trigger. I have a script attached to the trigger that is trying to turn on Mesh Renderers of gameobjects I am using of my HUD (using the tag "hud"):
var waitTime : float = 0.0; var hudFind : GameObject;
function OnTriggerEnter ( other : Collider ) {
if ( other.transform.tag == "Player" ) { turnOn(); } }
function turnOn () {
WaitForSeconds(waitTime);
hudFind = gameObject.Find("hud");
hudFind.renderer.enabled = true; }
No errors. The Hud is made of different planes that are attached to the camera so they follow the character as he moves along.
Then it may not be triggered. One of the colliders must have a rigidbody to collide things.
Answer by Sundar · Oct 24, 2012 at 04:03 PM
Try this
function turnOn () {
WaitForSeconds(waitTime);
hudFind = gameObject.Find("hud");
hudFind.GetComponent<MeshRenderer>().enabled = true;
}
What is $$anonymous$$eshRenderer meant to be replaced with? It just causes errors
Your answer
Follow this Question
Related Questions
How can I check if a GameObject has a Mesh? 1 Answer
Turn on mesh renderer when cam is looking. 1 Answer
Render VBO on GPU through MeshRenderer 1 Answer
Setting up a Skinned Mesh Renderer in Unity via Script 0 Answers
Modifying SkinnedMeshRenderer.sharedMesh.uv Doesnt Reset after Stopping game. 1 Answer