K
KingJoshington

Possible to start the sound file too "late" in the animation?

I'm not sure if this question makes sense, but, if we have this: 

    var sound_start_position: float = randf() * audio_player.stream.get_length()
    audio_player.play(sound_start_position)

and randf( ) says: 

Returns a random floating point value on the interval [0, 1].

randf() # Returns e.g. 0.375671


Then, is it possible that randf( ) could return a float like 0.999999 and then the starting position of the audio file would be so close to the end of the audio file that it would finish before the end of the text? 

I realize that this is unlikely because you'd need a LOT of luck with the randf( ) and a particularly long dialogue. 

I think to get around that there could be some sort of "loop" option when playing the audio, maybe?

  • Xananax replied

    You're right, it technically is possible, and it the file is not very long, then in 10% of the cases, you'd get a very short file.

    But indeed, as you say, there is a loop option. This option gets set on the file (not on the AudioStreamPlayer nor in the code).

    If you click on the file and then on the "import" tab, you can see the "loop" option is set

    If you wanted to change any option here, you need to click "reimport" for the changes to apply.

    1 love
  • K
    KingJoshington replied

    Thanks for your reply! It was quite calmly delivered ;)