How do you say in between for an if statement?

How would I say:

function Update () { if(transform.position.x "is in between number x and number y") { ( "do stuff" ) } }

You need to do :

if( transform.position.x >= A && transform.position.x <= B ) ...

What you need to see here :

  • A must be lower than B
  • if you want an exclusive interval, don't use >= but > etc
  • The use of && means that both statement MUST be true.

not sure if there is a better way, but you could just have nested if statements

if (x<100)
{
  if (x>50)
   {
    print ("we're now in between 50 and 100... woohoo!!");
   }

}