Best way of storing and loading a PackedFloat32Array on disk

Godot Version: 4.1.2-stable

Hi. I have a very long calculation on my project whose results are needed throughout the execution to improve hugely the performance of my game (for context: I need to store around 100,000 floats). The whole calculation can take some minutes, so it’s not an option to perform it during a loading screen.

However, I thought that, since I only need the results, which are always the same for every execution of the game, I could calculate them once and store them on some file/resource forever. During the execution, the scene would only load it and save the PackedFloat32Array on a variable.

Therefore, my question is: what’s the best way of storing such a big packed array on my project and loading it to a scene?

FileAccess.store_var

As @matheusmdx mentions, FileAccess.store_var works for the task, although I found FileAccess.store_buffer more useful, since it allows controlling the stored data byte by byte, saving memory a lot of memory for large arrays of types that can be easily translated into bytes (such as numbers, strings or even booleans).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.