I accidently didn’t disable the loop in PathFollow2D
This is the path_enemy.gd
extends Path2D
@onready var path_follow = $PathFollow2D
@onready var enemy = $PathFollow2D/Enemy
func _ready():
path_follow.set_progress_ratio(1)
func _process(delta):
path_follow.progress_ratio -= 0.25 * delta
if path_follow.progress_ratio <= 0:
queue_free()
When I started the main scene everything seemed fine, after the enemy left the scene it didn’t appeared again.
This is pretty easy to miss,if you run the path_enemy scene, its gonna loop and the queue_free() will never be called.
In the main scene however the same will happen, except there is a Deathzone:
So it will remove the enemy, but not the PathEnemy (Path2D) node.
EDIT in the next lesson its mentioned: Progress ratio never gets to exactly 0 or less than that