if statement

Hi there,

Is there any one out there who can explain to me what I am doing wrong with my little code here. I want to activate two other object if the statement meets the requirement in my IF statement. So it needs to meet two or more to set it active. but this is not making it work. Can anyone assist?

if (boxDestroy.length == 0 && boxDestroy2.length == 0){
             Debug.Log("MenuActivated");
             Wait();
             secondCamera.SetActive(true);
             passedObj.SetActive(true);
             myTimer= 0;
             
         }

There doesn’t seem to be any thing wrong with the code, but if it’s never enter the block that’s because the length of both boxes is never 0 at the same time. If you re changing the length variable from user interaction, i.e. not incrementally like with mouse drag, the value will never be exactly 0 so it’ll never enter that block. If you are setting the lengths by code then it can be 0. You could check for a range instead of the value being exactly 0.

if ((box1.lenght > -0.01 && box1.length < 0.01)  && (box2.length > 0.01 && box2.length < 0.01))
   ...