Help plz, im new and confuddled

Godot Version
Godot 4

Question
Hello, I am still relativley new to godot and am trying to make a game, I have this code here:

extends Area2D

var summon_timer = 0.0
const INTERVAL = 10.0

func _ready():
summon_timer = 0.0

func _process(delta):
summon_timer += delta

if summon_timer >= INTERVAL:
	play_summoning_animation()
	summon_timer = 0.0

func play_summoning_animation():
var animation_player = $AnimationPlayer
if animation_player:
animation_player.play(“Summoning”)
animation_player.connect(“animation_finished”, Callable(self, “_on_animation_finished”))

func _on_animation_finished(anim_name):
if anim_name == “Summoning”:
spawn_enemy_scene()

func spawn_enemy_scene():
var enemy_scene = preload(“res://enemy.tscn”)
var enemy_instance = enemy_scene.instance()
add_child(enemy_instance)
enemy_instance.position = position

But it does not seem to actually summon the child node, or it does but instatnly crashes with the error code "Invalid call. Nonexistent function ‘instance’ in base ‘PackedScene’ ". I cant quite seem to figure out what is wrong with it and it would be much appreciated if someone could help me out

.instance() was changed to .instantiate() in 4.0; try that out!

4 Likes

Omg, I was following a tutorial from an old version, Tysm! Cant beleive I didnt relise that🤦

1 Like