Godot Version
4.4
How does Audio work? in talking State i set sound to play if button pressed play() and if relased Stop() but doesnt work i tried to set playing to true then false if released it makes audio only works after i let go of Pressed Key and has to do it again to turn off audio,
i also added a flying sound it works when i press key i set and it supposed to stop playing if im on floor but it doesnt also how to make flying audio onl play if im on State Fly and FlyF state and only stop if character is not on any of 2 states? Heres my code
func _fly_state():
print("fly")
if Input.is_action_just_pressed("Fly"):
$Audio/Fly.play()
elif is_on_floor():
$Audio/Fly.stop()
animated_sprite.play("Fly")
if Input.is_action_just_pressed("Fly"):
velocity.y = JUMP_VELOCITY
elif velocity.x < 0 or velocity.x > 0:
current_state = States.FLYFORWARD
elif is_on_floor() and velocity.x < 0 or velocity.x > 0:
current_state = States.WALKING
elif velocity.x == 0 and is_on_floor():
current_state = States.IDLE
func _talk_state():
print("Talking")
if Input.is_action_pressed("EnterCall"):
if Input.is_action_pressed("Call"):
print("Call")
$Audio/Call.play()
elif Input.is_action_just_released("Call"):
$Audio/Call.stop()
if Input.is_action_just_released("EnterCall"):
current_state = States.IDLE