Script code for 'and' isn't working

Hello,

I am trying to make something working, but for reasons I do not know, it is not working. I have made a script to activate a particle flame when you’re inside the trigger zone of the flame. That works fine!

I want to activate an animation if all flames are on, but for some reason it does not work. My guess, it has to do with the &&. This is my script:

    #pragma strict
    
    var flame:Transform;
    
    var flame1 = false;
    var flame2 = false;
    var flame3 = false;
    var flame4 = false;
    
    static var allFlame = 0;
    
    //var flameStart = false;
    var onFlame = false;
    
    function Start () 
    {
    	flame.active = false;
    }
    
    function Update () 
    {
    	if(onFlame && Stefan_Player.gotTorch)
    	{
    		flame.active = true;
    		
    		if(flame.name == "Flame1")
    		{
    			print("flame1 is on");
    			flame1 = true;
    			
    		}
    		
    		if(flame.name == "Flame2")
    		{
    			print("flame2 is on");
    			flame2 = true;
    			
    		}
    		
    		if(flame.name == "Flame3")
    		{
    			print("flame3 is on");
    			flame3 = true;
    			
    		}
    		
    		if(flame.name == "Flame4")
    		{
    			print("flame4 is on");
    			flame4 = true;
    		}
    	}
    	
    	if(flame1 && flame2 && flame3 && flame4)
    	{
    		print("freaking BURRN!!");
    	}
    }
    
    function OnTriggerEnter( hit : Collider )
    {
    	if(hit.gameObject.tag == "Player" )
    	{
    		onFlame = true;
    	}
    
    }
    
    function OnTriggerExit( hit : Collider )
    {
    	if(hit.gameObject.tag == "Player" )
    	{
    		onFlame = false;
    	}
    
    }

The script is on each flame? That means flame1 has flame1-4, flame2 has a different flame1-4 … . When flame2 goes on, it sets it’s personal flame2 to true. But it’s personal 1,3,4 will always be false. When all 4 flames are on, each one sees 1 true and 3 falses in their personal flame1-4 vars. Trick is to have a “master” variable that tells you if a certain flame is on.

I’d lose flame1-4, and keep OnFlame, except never set it false. Seems it would be simpler to just lose Update and simply set stuff in OnTrigger. But, either way, you now have 4 total flame vars – each script has an OnFlame.

To check all 4, check onFlame for each trigger: if(GameObject.Find("fire1").GetComponent("fireScript").onFlame && ...).