Boolean in Physics Process

Godot Version

4.2 Mono

Question

I have a Boolean playerSeen that starts false. In the following code if i set the check to !playerSeen then the code runs however if i set it to playerSeen despite confirming the boolean is being changed none of the code ever runs as if the physics process refuses to read the new value…

 public override void _PhysicsProcess(double delta)
    {
		velocity = Velocity;
			
		if (!IsOnFloor())
			velocity.Y += gravity * (float)delta;
		
		if (playerSeen)
		{
			GD.Print("WORKING");
			velocity.X = 30;
		}
			
		Velocity = velocity;
		MoveAndSlide();
	}

Obviously, it depends on where you made the check and what happens afterwards.
You aren’t showing any of that so we can only guess.
One thing you can do is change playerSeen from boolean to a string and give it three possible values "init", "true", "false".
Where you initialize the variable string playerSeen = "init"
Where you believe you are changing it playerSeen = "true"
Where you are testing it:

if (playerSeen == "true") {
...
}else if (playerSeen == "false"{
...
}else{
...//playerSeen wasn't changed after all.  
}

i just figured it out, I needed to make my Boolean static