0 votes

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 cleartower() which calls updatepath()

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.

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

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

func _physics_process(delta):

if update_path == 1: 

So the only difference is that when i call for updatepath from process it will update. but when i call it from outside of process (ui) it will run updatepath 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 !

in Engine by (184 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.