Good morning !
Bit new to godot and python, following many tutorials and testing things.
I was able to make my own version of a tutorial about tower defense.
Instead of having a pre-made path, i decided to use the towers to create the maze.
And so far so good ! Monsters adapt everytime i put a tower.
But. If a monster has spawn by the time i put a tower down, it will walk through it and ignore it. (Monsters spawn after i place the tower down will take the tower in consideration.
I think this is an easy fix.
Every-time I put down a tower, I need to refresh ALL enemy's path at once.
Problem is, i have no clue on how to update multiple "$entities.addchild(mobinstance)" at once.
I tried to google some solution, but i honestly don't even know what look for...
Any tutorial or idea on how i could take care of this ?
Here are 2 pieces of codes that matter :
When I place down a tower :
#Need to add "If path_available" function to the IF
if can_build and not in_menu:
var new_tower = current_tower.instance()
new_tower.global_position = Map.map_to_world(current_tile)
#UPDDATE PATH OF ALL CHILD MONSTERS HERE
When I spawn a monster and create available path :
var mob_instance = mob.instance()
#define STARTING psition and DESTINATIOnn
mob_instance.position = $start_position.position
mob_instance.destination = $end_position.position
#Define the path it will follow :
var path = $Nav.get_simple_path($start_position.position, $end_position.position)
#add the mob to the entities container
if mobs_remaining > 0:
mobs_remaining -= 1
mobs_remaining = 0
Thanks for your time