0 votes

E 0:00:00.660 loadinteractive: Cannot open file 'res://scenes/tile.tscn'.
<C++ Error> Condition "err != OK" is true. Returned: Ref()
<C++ Source> scene/resources/resource
formattext.cpp:1232 @ loadinteractive()
Main Scene.gd:3 @ init()
E 0:00:00.663 _load: Failed loading resource: res://scenes/tile.tscn. Make sure resources have been imported by opening the project in the editor at least once.
<C++ Error> Condition "found" is true. Returned: RES()
<C++ Source> core/io/resource
loader.cpp:282 @ _load()
Main Scene.gd:3 @ _init()

Somehow it run once after loading files into inspector but now also throws this error in debugger stack frames gd 4 at function:_init
extends Node2D

var scene = load("res://scenes/tile.tscn")
var sceneinstance = scene.instance()
func scenadd():

Declare member variables here. Examples:

var a = 2

var b = "text"

Called when the node enters the scene tree for the first time.

func _ready():
pass # Replace with function body.

Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):


Godot version 3.3.2
in Engine by (54 points)
edited by

Please post the full debugger message, you haven't given us really anything to go off of to help you.

1 Answer

0 votes
Best answer

You need to give Godot a chance to fire up with:

Change var scene = load("res://scenes/tile.tscn") to var scene = preload("res://scenes/tile.tscn")

Move the rest of the code within your _ready method. As the default comments say, that fires when your node is good to go. In Godot, you can only declare member variables outside methods, everything else should go in a function. Like this:

extends Node2D

var scene = preload("res://scenes/tile.tscn")

func _ready():
    var scene_instance = scene.instance()

ps. You see the little curly braces above when you type? Just highlight the code and click that, it'll be a million times more readable.

by (2,047 points)
selected by

Godot Forum doesn't have the insert code so I didn't expect it here

Oh, don't worry in the slightest. I only mentioned the formatting because it made the problem easy to miss and so you'll know next time. Good luck with your game!

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 Frequently asked questions and 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.