|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
umma |
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():
pass
if Input.is_action_pressed(“ui_up”):
walk.play()"
can someone help? it only works if i use “action_just_pressed”
but that is not accurate.
|
|
|
 |
Reply From: |
Yaann |
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.
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.is_action_pressed(“ui_left”) and (is_on_floor() or ground_check.is_colliding()):
walk_sound.play(“Walking_Sound_Anim”)
elif Input.is_action_just_released(“ui_left”):
walk_sound.stop()
walking.stop()
yeah it’s good, that’s how it is supposed to work!