Still working on the framework sim thing that I’ve been working on but now I have come back from a break yet I am stuck on the same issue.
Put simply, no object beyond the base Node2D that everything parents to is allowed. Not to start with. The code reads a txt file and deciphers a list of commands to build a scene. What I am having trouble with is the command(s) that manages sound, as it creates the object and assigns the path fine, but it is unable to load the stream and/or the resource.
I tried to decipher documentation to iron out the issue. I was never able to.
Code
elif Local[0].to_lower() == "sound" and len(Local) == 2: #120
print("Command:Sound") #121
ActiveInstances.append(AudioStreamPlayer.new()) #122
add_child(ActiveInstances[-1]) #123
var a = AudioStream.new() #124
a.set_path(exePath + Local[1]) #125
ActiveInstances[-1].stream = a #126
ActiveInstances[-1].play() #127
ActiveInstances[-1].set_script(load("res://SoundManager.gd")) #128
ActiveInstances[-1].called() #129
Variables
Local → Splits the command into chunks and stores it as an array
ActiveInstances → A list of every object currently active. Meant for easy access, and mostly used to remove the objects when changing scenes.
exePath → The location of the executable
a → Often used when a command needs to create something then delete it immediately after.
res://SoundManager.gd → Two print commands. That’s it. Meant to delete the object once the audio completes, but thats not coded in at the moment
What I want to happen is as follows:
- Player is created
- Stream is created
- Stream is assigned an audio file
- Player is assigned the stream
- Player plays the audio file
But unfortunately, that just doesn’t happen.
Errors
E 0:00:09:543 Maker.gd:127 @ Manage(): Required virtual method AudioStream::_instantiate_playback must be overridden before calling.
<C++ Source> servers/audio/audio_stream.h:172 @ _gdvirtual__instantiate_playback_call()
<Stack Trace> Maker.gd:127 @ Manage()
Maker.gd:239 @ _process()
E 0:00:09:543 Maker.gd:127 @ Manage(): Failed to instantiate playback.
<C++ Error> Condition "stream_playback.is_null()" is true. Returning: stream_playback
<C++ Source> scene/audio/audio_stream_player_internal.cpp:150 @ play_basic()
<Stack Trace> Maker.gd:127 @ Manage()
Maker.gd:239 @ _process()