fuzzyworld

godot-shooter / commit

Only reset destination when a player touches it.

6e5e56fe66d8894866d28abea24f80cc42ca0d4e · Pavel Safronov · 2023-11-02 11:37:41 -0700 · parents 0a565f7c6653

Only reset destination when a player touches it.
 World.gd | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/World.gd b/World.gd
index 2d09317..4a6cac9 100644
--- a/World.gd
+++ b/World.gd
@@ -23,6 +23,8 @@ func add_new_enemy(should_be_visible: bool = false) -> void:
 	var pos = unit_vector * enemy_spawn_dist + $Player.global_position
 	
 	var enemy = Enemy.instance()
+	enemy.health = 1
+	enemy.max_health = 10
 	enemy.connect("enemy_killed", self, "_on_enemy_killed")
 	enemy.position = pos
 	enemy.add_to_group("enemies")
@@ -54,8 +56,9 @@ func set_destination(pos: Vector2) -> void:
 	$Destination.visible = true
 	$Player.	global_rotation = global_position.direction_to(get_global_mouse_position()).angle() + PI/2.0
 
-func _on_Destination_body_entered(_body: Node) -> void:
-	is_destination_set = false
+func _on_Destination_body_entered(body: Node) -> void:
+	if body == $Player:
+		is_destination_set = false
 
 func sort_enemies_ascending_distance(a: Enemy,b: Enemy):
 	var distA = (a.global_position - $Player.global_position).length()