Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Trigger enabling component works in one statement but not another?

$
0
0
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; } }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>