Code behaves unexpectedly when not in FixedUpdate

Hi, my problem is that part of my code behaves in a strange way sometimes, not as logically would expect from reading the code. After a bit of messing with the code I tried using a fixed update instead of a normal one and this seems to solve the problem. I would like to know where the problem is, can you help me understand why this happens?

This is part of the code, i’m almost certain the rest is not relevant cause i made some tests.

class Logic:

public static bool isActive = false;
private OrderedList<Character> inTurn;
public static GameObject entityTurn;

void Update () {
				while (!isActive) {
						if (inTurn.count > 0) {
								isActive = true;
								Character c = inTurn.removeFirst ();
								entityTurn = c.gameObject;
								c.chooseAction ();
						} else {
//NOT RELEVANT CODE
						}
				}
		}

class Character:

private bool isSelecting = false;
		void Update () {
				if (isSelecting) {
					
				 if (Input.GetKeyDown (KeyCode.Alpha8)) {
								isSelecting = false;
								turn = 40;
								
								hasMoved = false;
								hasAttacked = false;
								Logic.isActive = false;			
						}
				}
		}
	
		public void chooseAction () {
				if (!hasMoved || !hasAttacked)
						isSelecting = true;
				else {
						turn = 0;
						hasMoved = false;
						hasAttacked = false;
						//Logic.isActive = false;	
				}
		}

There is only one gameobject that has a Logic script attached and multiple gameobjects that have the Character script attached.

The problem is that sometime, even if isActive (in Logic) is true(so, there is an active selected character), the program enters the loop again and enables isSelecting for another characters and when i press the input key it takes the input two times, skipping one of the characters taken from the inTurn list. The only thing that can make isActive true is the end of the input if, so again the input must be taken twice to make the loop enter the second time(when it shouldn’t). This makes no sense to me one condition that causes the problem is activated only if the other is activated and vice versa.

As I said using a FixedUpdate in the Logic class seems to solve the problem but i don’t understand why.

Sorry if my description is not the best but I’m not really sure what the problem is.

Well, are you sure that in your character script line 23 is commented out? If not it could use up all your characters at once since you use a while loop in your “logic” script.

Also your condition inside chooseAction looks a bit strange to me. You always set isSelecting to true except when hasMoved and hasAttacked are true.

It would make more sense to put the input check into your logic script to have it at one place. Same for your isSelecting. It’s easier to use a variable of type “Character”. If it’s null nothing is seleced otherwise it holds the one Character you’ve selected.

From those code snippets it’s hard to determine the actual use of those two scripts. Some more background would help i guess.