Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document loading maps at runtime from game resources #10

Open
DeerTears opened this issue Mar 4, 2023 · 1 comment
Open

Document loading maps at runtime from game resources #10

DeerTears opened this issue Mar 4, 2023 · 1 comment

Comments

@DeerTears
Copy link
Member

QodotPlugin/qodot-plugin#159

You can load maps and build them at runtime by setting a QodotMap's map_file to your map, then calling verify_parameters(), then build_map() on the node.

I remember people running into dependency errors with their export settings, so I'm hoping someday I can write out the full method for this (including export settings) and add it to the docs.

As an alternative to supporting runtime loading, depending on the project, you can save your complete QodotMap builds as .tscn scenes, and just load those scenes. It's undeniably faster to load Godot's own data structures from your hard drive than it is to perform the entire build process in QodotMap which relies on various multithreaded API calls.

@Derpford
Copy link

Derpford commented Mar 4, 2023

Posting both to be subscribed to this and to write down the use case/reasoning for wanting to load maps at runtime.

My goal was to be able to write the game's gamemode logic (scoring, player spawning, etc) and keep it logically separated from the maps themselves. There's 3-4 approaches to this that I can think of, off the top of my head:

  1. Create a scene for the gamemode logic, then instance it in each map scene. Most effort-intensive. This also means that fanmade maps will need to be .tscn files instead of map files. IDK what the modding workflow would be for this, but apparently Your Only Move Is HUSTLE has a modding workflow where modded characters are .tscn files, so that's somewhere to look for details. To cut down on duplicate scene files, you could add every valid gamemode logic scene to a map, and then use some logic on loading the map to control which gamemode node is "active".
  2. Create a scene for the gamemode logic, which handles the process of loading the map by setting the QodotMap's map_file, calling verify_parameters(), and then calling build_map(). This is what I tried to do.
  3. As above, but instead of loading the map file, load a scene with the map file already packaged in it. More performant (though I'm not sure how much it matters) and harder to break than 2. Same concerns about modding as 1.
  4. Create a scene for each map, but instance the gamemode logic scene on map load. Similar to 2/3 in terms of effort saved. May not be meaningfully different from 3.

This is important because common use cases--like "I want to have multiple gamemodes that need to have separate logic, and multiple maps that might be valid for different gamemodes"--are exactly what people will want to learn about from the documentation. When someone looks up how to load a map at runtime, this is one of the questions they'll probably be trying to answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants