Godot Version
4.5 Stable Mac OS
Question
How do you make step sounds synchronise with walk animation of character3dbody ?
I was looking in TPS Demo , there is placeholder for step sound but was never used , rest like jump, shoot are using code like
in player_input.gd
# This is handled via RPC for now
@export var jumping := false
if Input.is_action_just_pressed("jump"):
jump.rpc()
@rpc("call_local")
func jump():
jumping = true
and player.gd
enum ANIMATIONS {JUMP_UP, JUMP_DOWN, STRAFE, WALK}
const JUMP_SPEED = 5
@onready var sound_effect_jump = sound_effects.get_node("Jump")
@onready var sound_effect_land = sound_effects.get_node("Land")
if anim == ANIMATIONS.JUMP_UP:
animation_tree["parameters/state/transition_request"] = "jump_up"
elif anim == ANIMATIONS.JUMP_DOWN:
animation_tree["parameters/state/transition_request"] = "jump_down"
rpc("call_local")
func jump():
animate(ANIMATIONS.JUMP_UP)
sound_effect_jump.play()
@rpc("call_local")
func land():
animate(ANIMATIONS.JUMP_DOWN)
sound_effect_land.play()
I’m trying to figure out how to make it for walk, I thought to use timer, but all results end up delayed or play nearly always 
Demo which I was looking inside GitHub - godotengine/tps-demo: Godot Third Person Shooter with high quality assets and lighting , unfortunately walk sound is not done in code, but asset is available
Ok I found this piece of info in Starter Kit FPS by Kenney in AssetLibrary
# Movement sound
sound_footsteps.stream_paused = true
if is_on_floor():
if abs(velocity.x) > 1 or abs(velocity.z) > 1:
sound_footsteps.stream_paused = false
interestingly it using 4.9 seconds long sample with is paused when velocity is lower , so not quite in sync but for FPS it do
Platformer using different approach
@onready var sound_footsteps = $SoundFootsteps
func handle_effects(delta):
particles_trail.emitting = false
sound_footsteps.stream_paused = true
if is_on_floor():
var horizontal_velocity = Vector2(velocity.x, velocity.z)
var speed_factor = horizontal_velocity.length() / movement_speed / delta
if speed_factor > 0.05:
if animation.current_animation != "walk":
animation.play("walk", 0.1)
if speed_factor > 0.3:
sound_footsteps.stream_paused = false
sound_footsteps.pitch_scale = speed_factor
if speed_factor > 0.75:
particles_trail.emitting = true
elif animation.current_animation != "idle":
animation.play("idle", 0.1)
if animation.current_animation == "walk":
animation.speed_scale = speed_factor
else:
animation.speed_scale = 1.0
it changing pitch based on speed_factor but also it doesn’t make sound of single step , so not sync properly
Thank you , I have read it but not sure how to use it as there is no example of AnimationTree combined animation and sound.
So It’s same like any other property just add key for play , but how to synchronise with , walk , run etc . I tried add like three but it sounds constantly when press walk no pauses like for steps , be great if there is some more info as steps are one of the basic thing to have synched to visual/ sound