- Home /
[CLOSED] renderer.enabled is set to true but does not show
I have this script which disables the renderer and collider of an object called "panel".
public class PanelDisable : MonoBehaviour {
private float timer;
public int disable_time;
public bool disabled;
void Start() {
disabled = false;
disable_time = 5;
}
void Update() {
if(disabled)
{
timer += Time.deltaTime;
print("Disabled");
rendered.enabled = false;
collider.enabled = false;
}
if(timer >= disable_time)
{
print("enable renderer");
renderer.enabled = true;
collider.enabled = true;
timer = 0;
disabled = false;
}
}
}
the boolean "disabled" is set to true by a bomb enemy (another gameobject), that explodes after 3 seconds upon spawning, and disables the nearest panel gameobject in this way:
if(intTime == 3)
{
FindNearestPanel().GetComponent<PanelDisable>().disabled = true;
Destroy(gameObject);
}
Well, the panel's collider and renderer are set to true when the bomb enemy explodes. However, both collider and renderer doesn't come back after 5 seconds. Everything I tried to print appears in the console, and if I check the inspector, the objects' collider and renderer are actually checked. BUT WHY IS IT THAT THEY DON'T SHOW :( It frustrates me, as I can't see what I'm doing wrong. Have I forgotten something? :(
Have you checked the rotation of the panel? $$anonymous$$aybe it's facing away from the camera and you are "watching" the back of it.
$$anonymous$$y panel is a 3D model, and the camera views it from the top. It doesn't even show on my scene view :(