Audio in _procces

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Erdo

I’m trying to add underwater sound effect and I need to detect this every frame.
But my sound effect only loops 0.1ms. How can ı fix that problem?

 func _process(delta):
    	if transform.origin.y < -7.2:
    		vel.y += 0.1
    		freeCamera = true
    		freeCamera = false
:bust_in_silhouette: Reply From: Dlean Jeans

Looks like you’re restarting the UnderWater sound every frame underwater.

if not $UnderWater.playing:

Bonus: if you don’t wanna start the sound at the beginning every time, record the playback position before you stop it:

var playback_pos = 0

if underwater:
    if not $UnderWater.playing:
    playback_pos = $UnderWater.get_playback_position()

Thank you very much. It worked!

Erdo | 2019-06-03 11:51