My IF statement called every frame 0.o

So this was for an attack script that I’m working on. The problem is I have an if statement and its called every frame. To test it out I even tried using the debug command. and here is the code.

void Update()
{
		if (Input.GetMouseButtonDown(0));
		{
			Debug.Log("Pressed button");
		}
}

But for whatever reason it sends that debug message every frame. any Ideas?

maybe you have collapse on the log set to on.

How would I correct that? (I’m sort of a nooby coder when it comes to unity)

The code does exactly what you’re asking it to do.
If you’d use Unity’s docs you’d find very simple code sample to do what you think you’re doing.

void Update()
{
		if (Input.GetMouseButtonDown(0));
		{
			Debug.Log("Pressed button");
		}
}

you may have missed it but you have an ; at the end of the IF statement. it should be:

void Update()
{
		if (Input.GetMouseButtonDown(0))
		{
			Debug.Log("Pressed button");
		}
}

Yep, what corrupted said. That should have been a compiler warning. Make sure you take a look at the console every once and awhile

MEGA FACEPALM thank you Corrupted, and no MonoDevelop didn’t warn me.

I may have only been coding for 2 - 3 years but still I feel like a noob atm haha -.-

It happens to the best of us. The reason why I believe it didn’t show any errors, with the ; , is because it is a perfectly legal statement, a pointless one but still legal.