0 votes

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
asked Jun 3, 2019 in Projects by Erdo (17 points)

1 Answer

+1 vote
Best answer

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()
answered Jun 3, 2019 by Dlean Jeans (3,911 points)
selected Jun 3, 2019 by Erdo

Thank you very much. It worked!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.