- Home /
Check renderer.enabled statement from another object
I want to check if a renderer of an object is enabled (true or false), i know kinda how to do this, but i can't get the final piece done. Here's what i have so far:
if (jump.GameObject renderer.enabled == true)
{
renderer.enabled = false;
}
I know this code is wrong, and i know it's inside the if statement, but i just don't remember how to do this..
What is 'jump'? Can you post the declaration for that variable?
Answer by Mike 3 · Mar 01, 2011 at 06:34 PM
remove GameObject:
if (jump.renderer.enabled == true)
assuming jump is a reference to your other object
Answer by Raymond 2 · Mar 01, 2011 at 07:28 PM
Okay for the ones wanting the same thing, this is my final code:
var jump : Transform ;
function Update() { if (jump.renderer.enabled == true) { renderer.enabled = false; } }
Answer by simplyRubbish · Mar 01, 2011 at 06:36 PM
Is jump your gameobject in question if it's renderer is enabled or not?
If so it should be:
if (jump.gameObject.renderer.enabled == true)
{
jump.gameObject.renderer.enabled = false;
}
Edit: (I forget if you actually need to use .gameObject so I included it to be safe)
Your answer
Follow this Question
Related Questions
if moving statement 1 Answer
using rotation in an if statement 1 Answer
How do you say in between for an if statement? 2 Answers
GUI box open on MouseButtonDown 1 Answer
if(object exists in scene) 2 Answers