# How do i make two if statements

how do i make two if statements for one set of actions?

It's called nesting.

``````if (condition1)
{
if(condition2)
{
//executes this code when the first condition is true AND the second is true
}

//executes this code when the first condition is true
}

``````

Almost the same as:

``````if(condition1 && condition2)
{
//Whether condition 1 is true or not doesn't matter, it only matters now if both conditions are true
//Making long strands of || && &! |* is called boolean logic
}

``````

Mind you that

``````if (!false)
{
//this code will be excuted
}

``````

what matters is the RESULT of the condition

And one more thing.

With all due respect, This question is not a question for the U N I T Y answers community, it's a basic all languages question. Please refrain from polluting the Q&A in the future if you can please. There's a whole load of descriptions just what and what not to post and even more double questions. They all try to achieve a single goal. Good Q&A quality. No more no less. I try the same so don't take it personal.

Anyway, hers some stuff you can follow:

``````var a:int = 1;
var b:int = 2;
var c:int =3;

``````

Heres an example of a standard if-else:

``````if (1 == a)
{
// Do a set of actions
}
else
{
// Do another set of actions
}

``````

Here's an example of multiple if-else statements:

``````if (1 == a)
{
// Do a set of actions
}
else if (2 -- b)
{
// Do another set of actions
}
else
{
// Do YET another set of actions
}

``````

Here's an example of a nested "if":

``````if (1 == a)
{
if (2 ==b)
{
// Do a set of actions
}
}

``````

Simple:

``````Var EyeColour = "Brown";
Var HairColour = "Blonde";

if(EyeColour == "Brown") //Which it does, so its going to return true
{
if(HairColour == "Pink") // Which it doesn't thus going to return false
{
print("Hair Colour is Pink");
}
else if(HairColour == "Blonde") // Which is true
{
print("Hair Colour is blonde");
}
}
else
{
print("Eye Colour is not Brown");
}

``````

Note: Because eye colour is Brown, it will return value of 'true', so when I ask javascript if EyeColour == "Brown" its going to check to see if it is, and if it is true, it will then ask about the hair colour.

Hair colour does NOT = pink, therefore anything within that if statement will be ignored, thus it will not print "Hair Colour is Pink", however, it will print "hair colour is blonde" simply because that if statement is true.

Another thing to remember is that, if the EyeColour did not equal brown, then none of this if statement will be called and it will go to the else statement and print "Eye Colour is not Brown".

(Colour = Color, I'm British)

--- Edit ---

This is basic JavaScript, I would advise you begin learning JavaScript before you dive into Unity