Cannot spawn scenes, losing my sanity help!
Asked Answered
S

2

0

I've spent a few hours at this but i'm beaten. Please see below a stripped down version of my code that contains anything that should be relevant at all to my problem. I just can't get the test_dot scene to spawn. It's a Node2d with (only) a sprite2d if that's relevant. I've read the official docs for 2d spawning but I'm beat!

` extends Node2D

@export var test_dot: PackedScene



func _ready():
    var test_dot = preload("res://test_dot.tscn")
    for i in range(10):
        for ii in range(20):
            var test_dot_instance = test_dot.instance() #  <--------- error here
            test_dot.global_position = Vector2(i, ii)
            add_child(test_dot_instance)


Error message is "Invalid call. Nonexistent function 'instance' in base 'PackedScene'."

`

Synovia answered 11/3 at 20:55 Comment(0)
D
0

In Godot 4, instance() was renamed to instantiate().

Donnydonnybrook answered 11/3 at 21:3 Comment(0)
S
0

Donnydonnybrook that works, my SINCERE thanks !!

Synovia answered 11/3 at 21:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.