Calling a function outside of _process (ui) but reading it as _process ? confused...

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By quizzcode

Hello there,
I’m hitting a wall on this one.

Working on a tower defense game where the towers are the maze.
When i “sell” a tower from the tower’s ui (NOT in physic’s process) i signal MAIN and
it sells the tower, replace the matching tilemap, queue_free the tower and… it’s supposed to update the path of all the enemies.

My function sell() calls clear_tower() which calls update_path()

Update_path looks like this :

	var enemies = get_tree().get_nodes_in_group("enemies")
for child in enemies:  #for each of them
	var path = $Nav.get_simple_path(child.position, $end_position.position) # we calculate their new path if any.
	child.set_path(path)
	

the problem is that the path won’t update,
It will go through but the mobs won’t adapt.

I use the same function update_path for when i place a tower, but from pysic_process and… it immediately update all monsters.

func _physics_process(delta):


if update_path == 1: 
	update_path()

So the only difference is that when i call for update_path from process it will update. but when i call it from outside of process (ui) it will run update_path but won’t actually work.

Any idea on how to approach this mysterious problem ?

extra info on selling :
I select my already placed tower from my “tower” scene.
Which ui.show() > sell button signal sell(body) to main scene

thanks !