Question by 
               TomBradshaw · Dec 20, 2016 at 03:20 AM · 
                javascriptscripting problemtriggercomponentcomponents  
              
 
              Trigger enabling component works in one statement but not another?
For the death/win screen of my game I've added a depth of field script that works for the win screen but not the death screen? It's the exact same code in the if statement and I've tried debugging it using
 print ("collider working"); 
 
               and it came up in the console but the components weren't activated.
 #pragma strict
 
 public var TestObj : GameObject;
 
 function Start () {
     (GetComponent("CameraOrbit") as MonoBehaviour).enabled = false;
     (GetComponent("DepthOfFieldDeprecated") as MonoBehaviour).enabled = false;
 }
 
 function Update () {
     if(CaffeineScript.Dead==true){
         print ("collider working");
         (GetComponent("DepthOfFieldDeprecated") as MonoBehaviour).enabled = true;
         (GetComponent("CameraOrbit") as MonoBehaviour).enabled = true;
     }
     else{
         (GetComponent("DepthOfFieldDeprecated") as MonoBehaviour).enabled = false;
         (GetComponent("CameraOrbit") as MonoBehaviour).enabled = false;
     }
     if(CaffeineScript.Win==true){
         (GetComponent("DepthOfFieldDeprecated") as MonoBehaviour).enabled = true;
         (GetComponent("CameraOrbit") as MonoBehaviour).enabled = true;
     }
     else{
         (GetComponent("DepthOfFieldDeprecated") as MonoBehaviour).enabled = false;
         (GetComponent("CameraOrbit") as MonoBehaviour).enabled = false;
     }
 
 }
 
              
               Comment
              
 
               
              Answer by TheyLeftMe4Dead · Jan 16, 2017 at 05:11 AM
Is this component attached to the death screen? That's all I can think of.
Your answer