0 votes


I'm trying to load resources (e.g. images) from "user://" path in GDScript and I got this error:

ERROR: _load_data: Condition ' !f ' is true. returned: ERR_CANT_OPEN
   At: scene/resources/texture.cpp:424
ERROR: Failed loading resource: res://.import/quest_background.png-eaaa035fe9ed74e4d9dc622678e6196d.stex
   At: core/io/resource_loader.cpp:186
ERROR: Failed loading resource: user://quests/q1/quest_background.png
   At: core/io/resource_loader.cpp:186

Here is my code example:

var image = load("user://quests/q1/quest_background.png").duplicate()

How can I achieve this?

Best regards,

in Engine by (104 points)
edited by

unless you placed an image on the user:// then the image is suppose to be in the res:// folder(if you placed it through the editor)

1 Answer

+2 votes
Best answer

This can be done by manually creating the image:

func crate_sprite(path):
    var img = Image.new()
    var err = img.load(path)
    if(err != 0):
        print("error loading the image: " + path)
        return null
   var img_tex = ImageTexture.new()

   var sprite = Sprite.new()
   sprite.texture = img_tex

   return sprite
by (104 points)
selected by
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.