+1 vote

I want to download dynamically an image from the server and than load it into the game
Is it doable in Godot?

in Engine by (17 points)

3 Answers

0 votes

you can download the content of files via the HTTPClient class.

here is an example:

by (293 points)
+1 vote

I had a try with a different method, there is a specialized function to choose where to put the file. I created a button for testing and an HTTPRequest node as child of it.
Then I added this script on the button:

extends Button

onready var _request = get_node("HTTPRequest")

func _ready():
    connect("pressed", self, "_on_button_pressed")
    _request.connect("request_completed", self, "_on_request_completed")

func _on_button_pressed():
    print("Doing request...")

func _on_request_completed(result, response_code, headers, body):
    print("Request completed ", result, ", ", response_code)

However the file arrived partially corrupted, with the following error:

ERROR: DVector<unsigned char>::resize: Condition ' mem.is_locked() ' is true. returned: ERR_LOCKED
At: c:\projects\godot-builds\godot\core\dvector.h:365

enter image description here

by (28,833 points)

When I did it none of the files I tried got corrupted at all.

0 votes

Thank you, I will check it

by (17 points)
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.