0 votes

i have 12 second walk sound audio, when press walk the aduio doesn't play instead it loops from 0 so it is just buffering and wont play the full audio. here is my code:

"extends KinematicBody

onready var walk = $AudioStreamPlayer3D

func ready():

if Input.isactionpressed("ui_up"):

can someone help? it only works if i use "actionjustpressed"
but that is not accurate.

Godot version godot 3.3
in Engine by (95 points)

1 Answer

+2 votes
Best answer

That's because you're calling the function every single frame with isactionpressed, I would suggest you instead to put the audio inside an AnimationPlayer, put it in a loop and call the animation instead.

by (224 points)
selected by

I tried it but it can't stop playing, the animation stops but the audiostream continues to play.

I figured it out now i had to write a script that stop the audio stream also, have a look:

if Input.isactionpressed("uileft") and (isonfloor() or groundcheck.iscolliding()):
elif Input.isactionjustreleased("uileft"):

yeah it's good, that's how it is supposed to work!

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.