My code does not run gdt4.2.1

Godot Version

4.2.1

Question

Every time I press play, it doesn’t execute and I get the error: Invalid call. Nonexistent function ‘instance’ in base ‘PackedScene’.

This is the code for my main scene that has a single 2d node
extends Node2D

Preload your scenes

var Escena1 = preload(“res://Intro.tscn”)
var Escena2 = preload(“res://Loadingmenu.tscn”)

This function will be called when the node enters the scene tree for the first time.

func _ready():
# Imprime la escena1 y escena2 después de pre-cargarlas
print(Escena1)
print(Escena2)

# Instance the first scene and add it to the current scene
var instancia_escena1 = Escena1.instance()
instancia_escena1.name = "Intro"
add_child(instancia_escena1)

This function will be called when the first scene is done

func _on_Escena1_done():
# Remove the first scene
get_node(“Intro”).queue_free()

# Instance the second scene and add it to the current scene
var instancia_escena2 = Escena2.instance()
instancia_escena2.name = "Loadingmenu"
add_child(instancia_escena2)

its instantiate() now I don’t know why they made that decision.

here is why

commit e28fd07b2bbe78db0f286604a6eb469d8a0664be
Author: Aaron Record
Date:   Thu Jun 17 16:03:09 2021 -0600

    Rename `instance()`->`instantiate()` when it's a verb

because of grammar

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.