More than or less than if statement issue. C#

Hello there,

So I wanted to make the following If statement:

	if(SwingTime == 0.6f && SwingTime > 0.4f){
	GUI.Box(new Rect(Screen.width/2-200,Screen.height/2-200,400,300),"",Pickaxe1);
	}
	else if( SwingTime == 0.4f && SwingTime >0.2f){
	GUI.Box(new Rect(Screen.width/2-200,Screen.height/2-200,400,300),"",Pickaxe2);	
	}
	else if( SwingTime == 0.2f && SwingTime >0){
	GUI.Box(new Rect(Screen.width/2-200,Screen.height/2-200,400,300),"",Pickaxe3);	
	}

As you can see the max time is 0.6, however when it goes to 0.5 the image goes blank and none of the others are working.

What I’m trying to do in code is basically what you lean in basic math :

0.4 < X < 0.6 Where X = that image being displayed.

Can anyone assist me please?

The way && statements work is if the first condition is true, it’ll check the second condition.

However, if the first condition is false, it won’t even bother checking the second condition.

So when X == .05, it’ll never make it past any of those first conditions.

If you want to check both conditions, use || instead of &&.
|| will check to see if the first condition is true, if it is true it won’t bother checking the second condition.

If the first condition is false, it’ll then check the second condition.