C# update code runs twice ?

Hello everyone,

i have an problem and can’t figure out why it happens. When i run this code, the switch case prints me two numbers. The whole IF statement runs twice, but why? The manouverDone bool is only after the secoond run “false”… ( i figured that out with that debug line). I have also used a lock object for the bool, same result.

void Update () {		
		if (maneuverDone){
			//Debug.Log("maneuverDone IF: "+maneuverDone);
			maneuverDone = false;
			nextManeuver = Random.Range(1,6);

			switch (nextManeuver ){
			case 5:
				print ("5");
				break;
			case 4:
				print ("4");
				break;
			case 3:
				print ("3");
				break;
			case 2:
				print ("2");
				break;
			case 1:
				print ("1");
				break;
			default:
				print ("Error");
				break;
			}
		}
	}

I don’t see any problem with your code. My guess is that you have accidently added the your script to two different game objects.

Why are you using print instead of Debug.Log(“…”)?