25
\$\begingroup\$

I always believed this was a feature only mobile games had, until I played world of warcraft and guild wars 2

To give you and example Tera Online takes 48 hours to download and completely instal if you don't have optic fiber internet.

But for WOW you literally just click on the .exe file and the game starts instantly, no need to install anything....the game downloads and installs the files you need as you are logging in and creating a character.

Is this possible in Godot? Has anyone ever did it using Godot?

\$\endgroup\$
5
  • 21
    \$\begingroup\$ As long as Gromit does not lay the track slower than the train is travelling, the train will not crash. It's not a full answer to your question but an intuitive explanation. Behind the scenes, there is a very high-pressure race to make sure things are ready by the time you need them, but from the outside it can look effortless. \$\endgroup\$
    – Flater
    Commented Jun 5, 2023 at 5:43
  • 40
    \$\begingroup\$ So you're not willing to be Waiting for Godot? \$\endgroup\$ Commented Jun 5, 2023 at 6:54
  • 1
    \$\begingroup\$ @JosephDoob i have many gb of assets to use, the life containing the player wearable hairstyles alone contains almost 240k polygons...imagine having to wait for all of that useless stuff to download on your computer before you can play. \$\endgroup\$
    – Cei
    Commented Jun 5, 2023 at 7:54
  • 9
    \$\begingroup\$ @Velsia - it was a joke comment (see en.wikipedia.org/wiki/Waiting_for_Godot) \$\endgroup\$ Commented Jun 5, 2023 at 9:09
  • \$\begingroup\$ I've cleaned up some comments that were wandering away from the topic of how to play a game that's still downloading content. Let's keep posts here focused on game development topics, and move to Game Development Chat if we want to pursue tangents into other areas of discussion. Also, @NotThatGuy, your 3 suggested ways would be better posted as an answer. \$\endgroup\$
    – DMGregory
    Commented Jun 8, 2023 at 15:59

2 Answers 2

29
\$\begingroup\$

I'm aware of a few games that do this, although none made with Godot. With that said, yes, this is possible in Godot.


You will have a background Thread, which goes down a list of data files to download, and downloading them.

With Godot, your first option for data files is pck files.

When you export a Godot game, Godot makes a pck file with all the Resources of the game... Godot loads and access this file using res:// paths.

You can create custom pck files from Godot using the PCKPacker class. And you can load custom pck files in runtime with load_resource_pack.

See also:

Beyond pck files, you have some other options:

  • You can also work with Godot file formats. On that note, using the binary formats for release (i.e. don't use .tres use .res, and don't use .tscn use .scn) will result in smaller file size.
  • Addendum: Godot 4 can also save and load glb/gltf file in runtime using GLTFDocument.
  • You can create your own formats. To add support to load them and saving them, create an EditorPlugin that installs custom ResourceFormatLoader and ResourceFormatSaver. Errata: The EditorPlugin should not be necessary for this use case.

Whatever your data files are, you will make them available for download from the server. If it is a web server, your game can download them using HTTP client class.

A multiplayer server might be able to send serialized Resources (including scripts). But I'll remind you that you cannot send instances.

I'll also remind you that the res:// paths are a representation of the contents of the pck files. So you don't download into there (as a matter of fact, the res:// are not writable in release). Instead you download the data files into user:// paths, and load them from there.

By the way, you can have different data files for different platforms, different languages, or whatever criteria you deem appropriate.


As you can imagine, the player might want to interact with something that is not ready.

You can use the order of the data files in the list of the server to make that situation less likely.

But to actually deal with the incident, you want a module that loads scenes on demand... If the scene is not available, queue the appropriate data file for download instead... And wait (which might mean showing a "loading" screen). And the background Thread should focus on whatever that module has queued.


I presume you don't want a "loading" screen...

Be aware that after downloading, the game needs to load the data files. And also loading and instancing the scenes takes time. So downloading the data files is not enough on its own to remove load times.

What you want is to load adjacent regions in a background process. And also unload distant regions.

See Background loading for Godot 4, or Background Interactive loading for Godot 3. You can use Area(2D/3D) for load triggers.

And to be able to load adjacent regions, the game will first demand them from the module I described before. That will also result in in downloading the associated data files early.

And thus the situation where the player tries to interact with something that is not ready (where you need the "loading" screen) is even less likely... But we cannot completely rule it out. For example, in the case of a network disconnection... In a multiplayer game, you would have the player reconnect. But in a single player game, it would be a "loading" screen.


You would release the game with whatever the data files need to work. But if loading a data file requires loading another first, your games needs to know the order. So you would have to annotate it in the server.

I want to point out that a bit of duplication is acceptable. For example, if the common dependency is a few functions, it is not worth it to create a data file for them. Instead duplicate them in the data files that need them.


Finally, you might also want to incorporate updates and integrity checks. In fact, it is a good idea to do this in the first release to avoid future headaches.

So you annotate in the server the version of the data files, so the game can check if it has the latest one. And also annotate a hash of the data files. So the game can do the hash, and compare the result with the server, without downloading the data file.

You could also use binary diff patches for the data files... In this case, the client would download the diff to update instead of doing a full download. Which results in downloading less data for an update. Yet, this is beyond the question.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Adding a bit to this excellent answer: For this to be practical, it needs to be possible to infer what resources are likely to be needed in the near future. MMOs can do that easily (things needed for areas connected to where the character is are more likely to be needed in the future than things on the other side of the world), but some games cannot. Without this, you’re generally too likely to run into a case where you need something that0s not available yet. \$\endgroup\$ Commented Jun 7, 2023 at 14:46
1
\$\begingroup\$

I'm not entirely sure which approaches are most common in practice, or how it's done in Godot, but to answer the title in the question:

On a highly oversimplified level, the 3 ways one could allow players to play a game before they've fully downloaded it is:

  1. Before you play, download the things you need in the early game. While you play, download the things you need later.

    You'd need to have resources for the starting area to start playing, but you probably won't need some late-game or end-game area until you've played for quite a while.

    If a player gets to a part of the game that hasn't been completely downloaded yet, you may need to force them to wait at that point. Or you could just restrict access to areas that haven't been fully downloaded yet.

  2. Before you play, download things required for play. While you play, download optional things.

    You can probably get by without some background textures or custom cosmetics, for example.

    Some of these things could be silently added once it's done downloading (like background textures for any new areas you load), while others would unlock certain functionality or items (like custom cosmetics).

  3. Before you play, download simplified versions of things. While you play, download the full versions.

    This could apply to graphics, for example: you could download low-res graphics before you start, and download high-res graphics while you play.

    You could silently replace the simplified versions with the full versions when e.g. players change areas.

Any of these can be done in batches of different sizes (from a single batch for everything, all the way to roughly every object being it's own batch), where the batch is applied to the game once it's finished downloading. More batches may be more complex (since you'd need to decide which batches to have), but it means a player can start playing earlier and there's less risk of getting into a situation where a player wants to do something they're not able to do yet, and/or the player ends up seeing full versions of things and being able to access optional content sooner (which would hopefully improve the player experience). This is especially relevant to slow connections.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .