Hello, this is the code I’m using to set a texture to true when other textures are set to false:
var textur : GUITexture;
function Awake() {
textur.enabled = false;
}
function OnTriggerEnter(){
if (GameObject.FindWithTag("top").GetComponent("Destroy")as MonoBehaviour).enabled = false &&
(GameObject.FindWithTag("left").GetComponent("Destroy1")as MonoBehaviour).enabled = false &&
(GameObject.FindWithTag("bottom").GetComponent("Destroy2") as MonoBehaviour).enabled = false &&
(GameObject.FindWithTag("right").GetComponent("Destroy3") as MonoBehaviour).enabled = false;{
textur.enabled = true;}
}
It almost worked, but the console expected something else and found “…” and I don’t see two periods in that style anywhere. I’ve tried to enclose the four statements in (), but that didn’t work either.
You have messed up all of your brackets as well as using the assignment-operator ( = ) instead of the equal-operator ( == )
function OnTriggerEnter()
{
if (
(GameObject.FindWithTag("top").GetComponent("Destroy")as MonoBehaviour).enabled == false &&
(GameObject.FindWithTag("left").GetComponent("Destroy1")as MonoBehaviour).enabled == false &&
(GameObject.FindWithTag("bottom").GetComponent("Destroy2") as MonoBehaviour).enabled == false &&
(GameObject.FindWithTag("right").GetComponent("Destroy3") as MonoBehaviour).enabled == false
){
textur.enabled = true;
}
}
The condition of an if-statement is always enclosed within brackets:
if (condition)
{
//body
}
condition is simply a boolean expression (true or false). If you have to use brackets within the condition-brackets, make sure you match the opening and closing brackets.