obsidian/MyObsidianVault/Godot/2D/Tutorial M7 - Telling a story/M7.L6 - Animating the text and playing sounds/2.) AudioStream.md

16 lines
379 B
Markdown
Raw Normal View History

2024-06-26 09:12:43 +02:00
Generic:
AudioStream
Positional:
AudioStream2D
AudioStream3D
`
```
var text_appearing_duration = 1.2 # value is in seconds
var sound_max_length := audio_stream_player.stream.get_length() - text_appearing_duration
var sound_start_position := randf() * sound_max_length
audio_stream_player.play(sound_start_position)
tween.finished.connect(audio_stream_player.stop)
```