FreekDS / GodotAudioEvents

A simple solution to generate events while playing a sound resource
MIT License
6 stars 0 forks source link

When first element in the eventTimes array is exactly 0.0 or 0.5, the first event won't be triggered #1

Open golddotasksquestions opened 10 months ago

golddotasksquestions commented 10 months ago

Tested in Godot 4.2.1 stable on Windows 10

Thanks for sharing this! I just followed your documentation and everything works great except for this little issue.

FreekDS commented 10 months ago

Thank you for trying it out! I tried reproducing the issue by adding 0.0 or 0.5 as first element in the array (in example.tscn) but it is working fine for me.

Can you provide me additional details and/or a minimal reproduction scenario? Thanks!

golddotasksquestions commented 10 months ago

Minimal Reproduction Project (Godot 4.2.1 stable):

AudioEvent_bug.zip

Note how the first event is set at 0.5 and does always play. I also added a timer to prolong the start, but that also does not help.

FreekDS commented 10 months ago

Thank you for the example, I was able to reproduce the bug some times.

I have done some initial testing and did not find the real answer yet. My guess is that it has to do something with how Godot initializes all nodes and resources.

Calling play on the audio stream player in the _ready function of the AudioEventPlayer does not seem to (always) work. Setting the autoplay property of the AudioStreamPlayer to true does not give the issue though... (at least I was not able to reproduce it in that case, can you verify?).

So as a short-term solution I would consider setting autoplay to true. I will do some additional testing and experiments to see if I can fix the problem though...

golddotasksquestions commented 10 months ago

My guess is that it has to do something with how Godot initializes all nodes and resources.

This was also my first guess, which is why I added timers to be sure all initialization of nodes is already over when I call play. The bug still was reliably reproducible for me. The strange thing is if I set the value above or below 0.5 it works well only exactly at 0.5 it does not.

FreekDS commented 10 months ago

Is it also reproducible with setting autoplay to true? I'd try to not start the AudioStreamPlayer in the _ready() function for now...