Screen shot here to show what I mean.
enemies spawn in with 0 health, immediately die and then pay out 15 gold without ever appearing.
in this second screenshot you can see the code commented out and the game working fine.
extends Path3D
@export var difficulty_manager: Node
@export var enemy_scene: PackedScene
@onready var timer: Timer = $Timer
func spawn_enemy() -> void:
var new_enemy = enemy_scene.instantiate()
new_enemy.max_health = difficulty_manager.get_enemy_health()
add_child(new_enemy)
timer.wait_time = difficulty_manager.get_spawn_time()
print(new_enemy.current_health)
I am unsure what is going on as when that specific line is added this issue occurs, when I comment the new_enemy.max_health = difficulty_manager.get_enemy_health()
line out of the code everything runs perfectly fine.
I have double checked everything is the same name across scripts in both enemy_path.gd and difficulty_manager.gd and that is the case.
I am using GODOT 4.2.2.stable, could there have been some kind of minor change or bug?