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?
Have you checked difficulty_manager.get_enemy_health() to make sure that it’s sampling from the curve correctly (and indeed that your curve doesn’t start with a y-value of 0)? It seems to me that this line is working correctly in the enemy scene, but it’s being fed 0-values by the difficulty manager.
Oh man I feel dumb, I came back in to this lecture this morning with fresh eyes and your comment helped me find it within a couple minutes!
At some point I had broken the link unintentionally to the difficulty_manager.gd from enemy_path.gd!
I just needed to reconnect the exported node for the difficulty_manager script on the inspector and now everything is working perfectly!
When I checked everything this morning it was showing “Assign” since it was not connected.