If i have the code
void OnTriggerEnter(Collider other)
{
if (other.gameobject.CompareTag("Pickup"))
{
other.gameobject.SetActive(false);
}
could i add the multiple lines for the if statement or would i have to make another if statement
it would look like this:
void OnTriggerEnter(Collider other)
{
if (other.gameobject.CompareTag("Pickup"))
{
other.gameobject.SetActive(false);
(gameobject.CompareTag("Blank"))
gameobject.Setactive(true);
}
}
im new to c#
i
What are you trying to do? You can use multiple arguments in the if statement with stuff like the && or || operators.
C# Operators
Otherwise, are you trying to do an else if?
if (other.gameobject.CompareTag("Pickup"))
{
// do code for Pickup tag.
}
else if (other.gameobject.CompareTag("Blank"))
{
// do code for Blank tag, but this is only checked if the first if results in false.
}
The || (or) operator would look like this
if (other.gameobject.CompareTag("Blank") || other.gameobject.CompareTag("Pickup"))
{
// do code for when the tag is either of those.
}
It’s not really clear what you’re trying to do, though.