0 votes

I am trying to import audio files from a "res://" directory, but load() is also loading in the .import files along with the audio. See here:

E 0:00:00.626   _load: No loader found for resource: res://audio/sfx/player/footsteps/HardFloor/Footstep_HardFloor_Hard_Variation1.wav.import.
  <C++ Error>   Method failed. Returning: RES()
  <C++ Source>  core/io/resource_loader.cpp:286 @ _load()
  <Stack Trace> FPCharacter.gd:76 @ GetSFXArrays()
                FPCharacter.gd:34 @ _ready()

There are 25 errors like this.

Here is my code for gathering the files:

func GetSFXArrays(pathHF, pathS):
    var HardFloorSFX = []
    var HF_SoundDirectory = Directory.new()
    HF_SoundDirectory .open(pathHF)

    var sfxHF = HF_SoundDirectory.get_next()

    while sfxHF != "":
        HardFloorSFX.append(load(pathHF + sfxHF))
        sfxHF = HF_SoundDirectory.get_next()

    HFSoundReturned = HardFloorSFX
Godot version 3.3.stable.official
in Engine by (23 points)

1 Answer

0 votes

So here's the thing: imported files can no longer be found on their original locations after export. They're all in the .import folder. So you'll need to look for the .import files, which are still in their original location. However, you can't load them. So what you need to do is to remove the .import from the file name.

file_name = file_name.replace(".import", "")

Now, just load the new file name. Even though the original file is not there anymore, the ResourceLoader can still load it from the name.

by (7,190 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.