0 votes

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

in Engine by (16 points)

3 Answers

0 votes

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

here is an example:
http://codetuto.com/2015/05/using-httpclient-in-godot/

by (289 points)
0 votes

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...")
    _request.set_download_file("the_thing.png")
    _request.request("http://docs.godotengine.org/en/stable/_static/docs_logo.png")


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 (27,170 points)
0 votes

Thank you, I will check it

by (16 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 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.

Categories