How can I download and load assets at runtime?

FoomfFoomf Posts: 2Member

I want my game to support user generated content that is served by a server. I want it to work very similar to, if not identical to how gmod works. I want to import models, sounds and textures.

The last time I checked, I was told this was not possible to do in godot. I'm checking in again, I'm sure a lot has changed since the last I asked this, so perhaps this functionality has been added.

The thing that worries me is that I'm circumventing the import pipeline. The godot engine generates an .assets file each time something is imported, but I want to load things that have not been imported, and thus do not have an .assets file.

I'm aware of load and preload, but as far as I know those only work with assets that have been imported.

Is it possible to accomplish what I want, or was godot not made for that kind of modding capabilities?

Thanks!


Tags :

Comments

  • MegalomaniakMegalomaniak Posts: 2,625Admin

    I'm not particularly familiar with how gmod works, but godots packed scenes might be of interest to you.

    Unless you are willing to implement the importing functionality into your game yourself the modders would need to use godot editor to import the assets(models sounds and textures) and set up the instantiable scene in godot and save it AFAIK.

    Preload actually compiles the asset into the game so that is not relevant to modding. load however ought to be.

    @Foomf said:
    Is it possible to accomplish what I want, or was godot not made for that kind of modding capabilities?

    Where there is a will there is a way. If the godot packed scene is not the way you want to go then you could create your own editor and fileformat and implement the logic to load data from that file and generate the object in your game from that data for an example. Essentially what Bethesta does with the .nif file format and their elderscrolls games editors.

  • TwistedTwiglegTwistedTwigleg Posts: 2,641Admin

    As @Megalomaniak mentioned, .pck files can be used for this. You just need to write the code that imports it, and then use it as normal. This page on the documentation covers a bit about how this could be done.

    You can also use Godot’s built-in File class, serialize data using that, and then import it at run-time using Godot’s built-in File class. I know it is doable, at least on a conceptual level, because I made a proof-of-concept plugin.

  • FoomfFoomf Posts: 2Member

    @TwistedTwigleg Awesome, this is exactly what I was looking for, thanks! Do I have the ability to not load any scripts using a .pck file? I want to load models and sounds and textures, but I don't want to load any executable code, since I think that would be a security risk.

  • TwistedTwiglegTwistedTwigleg Posts: 2,641Admin

    The plugin itself saves/loads the scripts attached to nodes/resources, but I think it can be configured to avoid this. If I remember correctly, I had to specifically add support for scripts, so it should be possible to disable it.

  • CalinouCalinou Posts: 410Admin Godot Developer

    Do I have the ability to not load any scripts using a .pck file? I want to load models and sounds and textures, but I don't want to load any executable code, since I think that would be a security risk.

    Right now, this isn't possible (even if you were to strip scripts when loading the PCK, they might still be run IIRC). There have been a few GitHub issues about excluding scripts when loading a PCK, but I can't find them right now.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file