how can i make that when bool variable is true or false this or that happens
please help
if (A && B)
{
//stuff to do if A and B are true
}
if (!A || !B)
{
//stuff to do if either A or B are false
}
1 Like
urumizawa has answered your question if you want multiple bools being checked for a single statement. If you only want one, we just adjust a little.
public bool isActive = false;
void Update()
{
// Here we check if isActive is true and if it is...
if (isActive)
{
// ...then we do stuff here
}
// Since a bool can only be two values we use the else statement to do anything we want if it's false
else
{
// Do stuff here
}
}
The better question is why people are giving C# answers in Unity Visual Scripting subforum.
1 Like
Oops. I have been in a different world recently. At any rate, you’ll want to right click, add variable type bool, then add a compare script and attach the bool to the bool node at the bottom of that and the true or false to their corresponding actions, and connect the input node to whatever you want to trigger that compare action.
EDIT – you’ll want to insert a “Toggle” function to change that bool btw.