Return to the MainLevel Scene
Select the MainLevel node
Add a Time node as a child
As can be seen above the tree is getting cluttered and as we spawn more Goblins it will get even worse.
We can create a Container to hold all current Goblins and newly spawned ones.
Using a dedicated container node (like Goblins or GoblinContainer) is great Godot practice, it keeps the Remote Scene Tree clean during playtesting, makes it easy to count active enemies ($GoblinContainer.get_child_count()), and allows you to clear all goblins at once if needed.
Select the MainLevel node
Rename it to GoblinContainer
Drag all current Goblin instances into it
Select the MainLevel node
Add an export variable for
Add ready reference variables for
Create the timout function
Because screen_size.x + 100
Is off-screen we must update the ready function OF GOBLIN to look at the player and move towards them
Update the ready function
Connect the SpawnTimers timeout signal
Create the custom died signal
Also change the spell scene reference to a constant
Inspector-Proof: Because constants aren't exposed in the Inspector, you can't accidentally break a reference by leaving an @export slot blank on an instance in the main scene.
Clearer Intent: Reserve @export var ...: PackedScene for nodes that genuinely vary per instance (such as a modular turret or spawner that swaps between different enemy or projectile types), and use const for fixed assets like a wizard's standard spell or an impact spark.
Create the on player died function
To allow the Goblin to kill the player
Add a body entered function in the
Connect the Goblin's body entered signal