I'm new to godot and I recently had a problem when adding footsteps in my game. The problem is that the footsteps play after the key is released and not when the key is pressed. To do that, I made an if sentence that says "If walking == true: $AudioStreamPlayer3d.play()". I already checked that the Walking variable is set to true when pressing W. I did a walking animation and it works perfectly, unlike the audio.
Here's a part of the code:
if Input.is_action_pressed("movement_forward"):
input_movement_vector.y += 1
Walking = true
if $CameraPivot/Camera/scene/SpotLight.visible == true:
$CameraPivot/Camera/scene/FlashLightAnimPlayer.play("FlashlightMove")
elif $CameraPivot/Camera/scene/SpotLight.visible == false and Input.is_action_just_pressed("Flashlight"):
$CameraPivot/Camera/scene/FlashLightAnimPlayer.play_backwards("FlashLightHide")
$CameraPivot/Camera/scene/FlashLightAnimPlayer.queue("FlashlightMove")
if Input.is_action_just_released("movement_forward"):
Walking = false
if Walking == true:
$AudioStreamPlayer3D.play()
Thanks in advance < 3