Why is there a load() at all?

all 11 comments

sorted by: hot top controversial new old
[–] 7 points 3 years ago* (5 children)

load() just loads things as soon as it's called, so it can be used if you're making an open-world game and don't want the whole map loaded into ram at once, or if you switch from one level to another maybe you want to load some new assets and unload the previous ones to save memory. If you're not worried about that you can just use preload() yeah.

  • source
  • hideshow 5 child comments
  • [–] 2 points 3 years ago (4 children)

    I personally have a 'game launcher' for all my separate projects which I'll usually only launch one from, so I exclusively use load()

  • source
  • parent
  • hideshow 4 child comments
  • [–] 3 points 3 years ago (3 children)

    Why did you do that? I've always just used the project manager. Is it that version manager plugin that was posted here a while ago?

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 3 years ago (2 children)

    Ngl cause all my code is a mess and I have a lot of 'addons' that I don't want to separate out but also haven't been finished independently yet. Its my ADHD workflow but it works for me, its all just one disgustingly large project

  • source
  • parent
  • hideshow 2 child comments
  • [–] 6 points 3 years ago (1 child)

    For a personal project, I'm using load() because I don't know which file I'm supposed to load when the scene starts. Also, said file can change during game runtime.

    In my case, I'm changing textures. With the game paused, the player can change some stuff, like the character's hair. I don't need to preload all of them, and maybe a preloaded one might not be the one that should actually be loaded in the end.

  • source
  • hideshow 1 child comment
  • [–] 5 points 3 years ago (2 children)

    In GDScript, there exists the global preload method. It loads resources as early as possible to front-load the "loading" operations and avoid loading resources while in the middle of performance-sensitive code.

    Its counterpart, the load method, loads a resource only when it reaches the load statement. That is, it will load a resource in-place which can cause slowdowns when it occurs in the middle of sensitive processes. The load() function is also an alias for ResourceLoader.load(path) which is accessible to all scripting languages.

    From the docs: https://docs.godotengine.org/en/stable/tutorials/best_practices/logic_preferences.html

  • source
  • hideshow 2 child comments