Godot Version
4.3
Question
This code is isloated from the project and it still functions the same way as it did in the project.
The focus_level variable is continually being depleted and I want to pause it from being depleted.
I’m trying to pause the deplete_focus() function from getting called in physics_process(), I have a boolean variable pause_focus_depletion that gets set to true which should prevent it from being called.
The Q key input is for sake of example, in the project the function get’s called externally.
extends Node
var pause_focus_depletion = false
var focus_level = 100.0
func _physics_process(delta: float) -> void:
if pause_focus_depletion == false:
deplete_focus()
print(focus_level)
if Input.is_physical_key_pressed(KEY_Q):
pause_depletion()
func deplete_focus():
focus_level = move_toward(focus_level, 0.0, .0005)
func pause_depletion():
pause_focus_depletion = true
print('paused')
When you press Q it does call the function evidenced by the output
But it deplete_focus() keeps getting called
If you step into the function the value does get set to true
But when you continue it get’s set back
I realize in some way I’m truely breaking the follow of things but I have no idea how. I’m guessing there’s a better way to handle this so please fire away with what I’m doing wrong.