Skip to main content
Indentation consistency
Source Link
DMGregory
  • 140.8k
  • 23
  • 257
  • 401

I have other scripts in the same project using boolean if statements that work fine, but I've tried multiple methods of testing if the if statements below are working and none of them worked!

I don't really know what to ask because I don't know whats going on. I've tried placing theae statements in Update and Start, and in both instances the if statement completely ignored the check and just executed the contents of the block as though the check evaluated to true.

void OnTriggerEnter(Collider other) { if(other.gameObject.CompareTag("Player")); { working = true; } Extremity = false; if(Extremity); {   Instantiate(Cannon, transform.position, transform.rotation);   Extremity = !true; } } 

The false statement is only in there to show that even when the bool is set to false immediately before the check, it still runs the Instantiate method inside as though it were true.

I have other scripts in the same project using boolean if statements that work fine, but I've tried multiple methods of testing if the if statements below are working and none of them worked!

I don't really know what to ask because I don't know whats going on. I've tried placing theae statements in Update and Start, and in both instances the if statement completely ignored the check and just executed the contents of the block as though the check evaluated to true.

void OnTriggerEnter(Collider other) { if(other.gameObject.CompareTag("Player")); { working = true; } Extremity = false; if(Extremity); {   Instantiate(Cannon, transform.position, transform.rotation);   Extremity = !true; } } 

The false statement is only in there to show that even when the bool is set to false immediately before the check, it still runs the Instantiate method inside as though it were true.

I have other scripts in the same project using boolean if statements that work fine, but I've tried multiple methods of testing if the if statements below are working and none of them worked!

I don't really know what to ask because I don't know whats going on. I've tried placing theae statements in Update and Start, and in both instances the if statement completely ignored the check and just executed the contents of the block as though the check evaluated to true.

void OnTriggerEnter(Collider other) { if(other.gameObject.CompareTag("Player")); { working = true; } Extremity = false; if(Extremity); { Instantiate(Cannon, transform.position, transform.rotation); Extremity = !true; } } 

The false statement is only in there to show that even when the bool is set to false immediately before the check, it still runs the Instantiate method inside as though it were true.

Formatting
Source Link
DMGregory
  • 140.8k
  • 23
  • 257
  • 401

If statements not checking, no clue whatseem to act as though the condition is going onalways true

I have other scripts in the same project using boolean if statements that work fine, but I've tried multiple methods of testing if this statement wasthe if statements below are working and none of them worked! 

I don't really know what to ask because I don't know whats going on. IveI've tried the statementplacing theae statements in update, startUpdate and Start, and in both instances the if statement completely ignored the check and just returned true, it is kindexecuted the contents of driving me insanethe block as though the check evaluated to true.

 `voidvoid OnTriggerEnter(Collider other) {   if(other.gameObject.CompareTag("Player")); {   working = true;    }     Extremity = false;   if(Extremity); {   Instantiate(Cannon, transform.position, transform.rotation);   Extremity = !true;   }` } 

The false statement is only in there to show that even when the bool is declaredset to false immediately before the check, it still returnsruns the Instantiate method inside as though it were true.

If statements not checking, no clue what is going on

I have other scripts in the same project using boolean if statements that work fine, but I've tried multiple methods of testing if this statement was working and none of them worked! I don't really know what to ask because I don't know whats going on. Ive tried the statement in update, start, and in both instances the if statement completely ignored the check and just returned true, it is kind of driving me insane

 `void OnTriggerEnter(Collider other){   if(other.gameObject.CompareTag("Player")); {   working = true;    }   Extremity = false;   if(Extremity); {   Instantiate(Cannon, transform.position, transform.rotation);   Extremity = !true;   }` 

The false statement is only in there to show that even when the bool is declared false immediately before the check, it still returns true.

If statements seem to act as though the condition is always true

I have other scripts in the same project using boolean if statements that work fine, but I've tried multiple methods of testing if the if statements below are working and none of them worked! 

I don't really know what to ask because I don't know whats going on. I've tried placing theae statements in Update and Start, and in both instances the if statement completely ignored the check and just executed the contents of the block as though the check evaluated to true.

void OnTriggerEnter(Collider other) { if(other.gameObject.CompareTag("Player")); { working = true; }    Extremity = false; if(Extremity); { Instantiate(Cannon, transform.position, transform.rotation); Extremity = !true; } } 

The false statement is only in there to show that even when the bool is set to false immediately before the check, it still runs the Instantiate method inside as though it were true.

Source Link

If statements not checking, no clue what is going on

I have other scripts in the same project using boolean if statements that work fine, but I've tried multiple methods of testing if this statement was working and none of them worked! I don't really know what to ask because I don't know whats going on. Ive tried the statement in update, start, and in both instances the if statement completely ignored the check and just returned true, it is kind of driving me insane

 `void OnTriggerEnter(Collider other){ if(other.gameObject.CompareTag("Player")); { working = true; } Extremity = false; if(Extremity); { Instantiate(Cannon, transform.position, transform.rotation); Extremity = !true; }` 

The false statement is only in there to show that even when the bool is declared false immediately before the check, it still returns true.