Switch animationplayer audio track on/off in gdscript

Godot Version

4.2.2

Question

I want to switch an audio track in the animationplayer on/off in gdscript to have different footstep sounds depending in the ground surface.

this is what I got so far, but no luck (also tried audio:Footstep and Audio: etc.)

	walk_animation = player.animation_player.get_animation("walk")
	track_index_to_toggle = walk_animation.find_track("Audio/Footstep", TYPE_INT)
	walk_animation.track_set_enabled(track_index_to_toggle, false)
	track_index_to_toggle = walk_animation.find_track("Audio/MetalStep", TYPE_INT)
	walk_animation.track_set_enabled(track_index_to_toggle, true)

And this is the animation player:

Thought of a much simpler way. Just turn both audio tracks on and then:

	player.footstep.volume_db = -80
	player.metal_step.volume_db = 2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.