physics process not detecting change in bool variable

Godot Version

4.5.1 + dialogic

Question

i wanna preface my question by saying i am VEERY new to godot (and programming), so please forgive if this is a very easy answer and i should probably know it </3… currently, im trying to make a system where once you interact with an npc, youll be frozen until the dialogue is over, where you will be unfrozen. i can get the player to freeze when dialogue is on screen but i cant seem to get them to unfreeze + its almost the exact same script. also, the script works right up until the physics process is changed. the _process function DOES run for both (as checked with a print) but when i try to print in the actual physics process, it only prints before the cant_move is set to true. if anything else needs explained, just ask! :smiley:

Add some print() statements in your code to see what’s being triggered and what’s not triggered to understand your problem better.

set_physics_process(false) stops _physics_process() from running. So, even if cant_move becomes false later, the code inside _physics_process() won’t get executed and thus will never reach the if-statement to re-enable processing.

Instead of changing the physics processing, you could just return from _physics_process() early when cant_move is true:

func _physics_process(_delta):
	if cant_move == true:
		set_process_input(false)
		return
	if cant_move == false:
		set_process_input(true)

This will prevent any other code below from getting executed (while cant_move is true).

oh my goodness… thank you so much…. LIFESAFER BRO I WOULDNT HAVE THOUGHT TO DO THIS…