0 votes

So I'm trying to make an endless runner and I took a code from the internet for the endless generation.
So here is the code:

extends Node2D
export (Array, PackedScene) var scenes

func _ready():
    add_wall()


func _physics_process(delta):
    pass


func add_wall():
    for scene in scenes:
        var object = load("res://Scenes/Objects1.tscn")
        var objectinstance = object.instance()
        objectinstance.position = Vector2(80, -200)
        get_parent().add_child(object)

If I run the code nothing happens, no error no warning just nothing. I tried different tutorials too, but there was no difference at the result. Whats wrong with the code?

in Engine by (44 points)

1 Answer

0 votes
Best answer

you should be adding the instance of the loaded scene, not the scene itself.
try this:

get_parent().add_child(objectinstance)
by (433 points)
selected by

Thanks for your answer

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.