Godot Version
Godot 4.4.1 latest
Question
god HELP me with this damn bug, i’ve been trying to fix it for SO LONGGGG
BASICALLY, i have a slide function, which basically lowers the camera and the player’s height, and there are alot of more sounds in my godot project which ALL WORK CORRECTLY. but for SOME reason. this SPECIFIC slide sound just REFUSES to play
i’ve added fixes, i’ve talked to chatgpt about it as a last resort, i’ve added so much sanity checks and THEY ALL PROVE THAT THERES THE SLIDE, BUT IT. JUST. WONT. PLAY
HELPPPP!!!
Without seeing any code, any screenshots of how that part of your project is structured, I highly doubt anyone will be able to help you.
Chill
Are you even okay?
I also have experienced this audio not playing,playing but looping forever even when stopped, it’s just annoying…
I don’t see code so I can’t really understand the problem but maybe the sounds are quickly playing all over again so you can’t hear them or you’ve assigned the AudioStreamPlayer incorrectly.
I think it’s an animation.
I don’t think sooo …
Maybe he/she went outside to smell a flower…
HEY, i haven’t checked the forums in a bit, sorry
and yeah im okay, and im a he
im gonna reply to this message with the full code
its just this damn sound has driven me INSANE bro
extends CharacterBody3D
@export var walk_speed = 5.0
@export var run_speed = 10.0
@export var slide_speed = 12.0
@export var slide_duration = 0.8
@export var jump_velocity = 8.0
@export var mouse_sensitivity = 0.005
@export var slam_velocity = 50.0 # downward push for slam
# WALL JUMP settings
@export var wall_jump_push := 3
@export var wall_jump_boost := 8.0
@export var max_wall_jumps := 3
@export var wall_jump_cooldown := 1.5
@export var wall_jump_lerp_speed := 20.0 # used for smoothing (frames)
# NEW: horizontal power scale to prevent being flung off the map
@export var wall_jump_power_scale := 0.0005 # 1.0 = original power, <1 reduces horizontal push
var bullet_scene = load("res://other_node_3d.tscn")
@onready var collision = $CollisionShape3D
@onready var camera = $Camera3D
@onready var animator = camera.get_node("MeshInstance3D/AnimationPlayer")
@onready var raycast = $Camera3D/MeshInstance3D/RayCast3D
@onready var gunshot = $Camera3D/MeshInstance3D/gunshot
@onready var walk = $Camera3D/MeshInstance3D/walk
@onready var run = $Camera3D/MeshInstance3D/run
@onready var slide = $Camera3D/MeshInstance3D/slide
@onready var jump = $Camera3D/MeshInstance3D/jump
@onready var superjump = $Camera3D/MeshInstance3D/superjump
@onready var land = $Camera3D/MeshInstance3D/land
@onready var superland = $Camera3D/MeshInstance3D/superland
var normal_height = 2.0
var crouch_height = 1.0
var normal_speed = 5.0
var crouch_speed = 10.0
var is_crouching = false
var sliding = false
var sliding_timer = 0.0
var walking = false
var running = false
var jumping = false
var superjumpp = false
var was_on_floor = true
# smoothing values
var target_height = .1
var target_cam_y = 1.5
var crouch_cam_y = 0.75
var smooth_speed = 10.0
# camera shake
var shake_time = 0.5
var shake_strength = 0
# NEW: camera base Y only (we lock X/Z to 0 each frame)
var cam_base_y = 1.5
# WALL JUMP runtime
var wall_normal := Vector3.ZERO
var wall_jump_count := 0
var wall_jump_timer := 0.0
var wall_jump_locked := false
# NEW: wall jump smoothing target + toggle
var wall_jump_target := Vector3.ZERO # target horizontal velocity (x,z) for smoothing
var wall_jump_smoothing_active := false # whether per-frame lerp toward wall_jump_target is active
var wall_jump_smoothing_eps := 0.05 # small threshold to snap to target
# LANDING debounce / airtime tracking (timer-based)
var air_time := 0.0
var land_cooldown_timer := 0.0
var land_cooldown := 0.25 # seconds minimum between land sounds
var min_air_time_for_landing := 10 # require this long in air to consider as "landing"
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
target_height = normal_height
target_cam_y = normal_height * 0.75
# initialize cam_base_y from target so it starts correct
cam_base_y = target_cam_y
# ensure camera local x/z are zeroed (prevents inherited offsets)
camera.position.x = 0
camera.position.z = 0
# set initial camera pos to locked base
camera.position = Vector3(0, cam_base_y, 0)
func _input(event):
if event is InputEventMouseMotion:
rotate_y(-event.relative.x * mouse_sensitivity)
camera.rotate_x(-event.relative.y * mouse_sensitivity)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-80), deg_to_rad(80))
# --- NEW HELPER ---
func is_really_on_floor() -> bool:
for i in range(get_slide_collision_count()):
var c = get_slide_collision(i)
if c.get_normal().dot(Vector3.UP) > 0.1:
return true
return false
func _physics_process(delta):
var direction = Vector3.ZERO
walking = false
running = false
# update land cooldown timer
if land_cooldown_timer > 0.0:
land_cooldown_timer -= delta
if land_cooldown_timer < 0.0:
land_cooldown_timer = 0.0
# wall jump cooldown tick
if wall_jump_locked:
wall_jump_timer -= delta
if wall_jump_timer <= 0.0:
wall_jump_locked = false
wall_jump_count = 0
wall_jump_timer = 0.0
# crouch/slam input
if Input.is_action_just_pressed("crouch"):
if is_really_on_floor():
_start_crouch()
else:
_slam_down()
if Input.is_action_pressed("crouch") and is_really_on_floor():
if not is_crouching:
_start_crouch()
else:
if is_crouching and sliding_timer <= 0.0:
_stop_crouch()
# smoothly adjust collider + camera base Y (we only change cam_base_y)
var shape = collision.shape as CapsuleShape3D
shape.height = lerp(shape.height, target_height, delta * smooth_speed)
cam_base_y = lerp(cam_base_y, target_cam_y, delta * smooth_speed)
# movement input
if Input.is_action_pressed("move_forward"):
direction -= transform.basis.z
if Input.is_action_pressed("move_back"):
direction += transform.basis.z
if Input.is_action_pressed("move_left"):
direction -= transform.basis.x
if Input.is_action_pressed("move_right"):
direction += transform.basis.x
# movement state
if direction != Vector3.ZERO:
if Input.is_action_pressed("run") and not is_crouching:
running = true
else:
walking = true
# footstep sounds
if is_really_on_floor():
if walking and not running and not walk.playing:
walk.play()
elif not walking:
walk.stop()
if running and not walking and not run.playing:
run.play()
elif not running:
run.stop()
else:
walk.stop()
run.stop()
if is_crouching and running:
slide.play()
else:
slide.stop()
# slide start
if Input.is_action_just_pressed("crouch") and running and is_really_on_floor() and sliding_timer <= 0.0:
slide.play()
sliding_timer = slide_duration
if not is_crouching:
_start_crouch()
if sliding_timer > 0.0:
sliding_timer -= delta
sliding = true
else:
sliding = false
sliding_timer = 0.0
if sliding:
walk.stop()
run.stop()
if not slide.playing:
slide.play()
else:
if slide.playing:
slide.stop()
# shooting
if Input.is_action_just_pressed("shoot"):
_shoot()
# current speed
var current_speed = normal_speed
if sliding:
current_speed = slide_speed
elif is_crouching:
current_speed = crouch_speed
elif running:
current_speed = run_speed
direction = direction.normalized()
# APPLY movement only if we are NOT currently overriding via wall-jump smoothing.
if not wall_jump_smoothing_active:
velocity.x = direction.x * current_speed
velocity.z = direction.z * current_speed
# gravity
if not is_really_on_floor():
velocity.y -= 20 * delta
# jump + wall jump (input handling)
if Input.is_action_just_pressed("jump"):
if is_really_on_floor():
if is_crouching and not sliding:
superjumpp = true
velocity.y = jump_velocity + 4
superjump.play()
elif not is_crouching:
jumping = true
velocity.y = jump_velocity
jump.play()
wall_jump_count = 0
wall_jump_locked = false
wall_jump_timer = 0.0
# Cancel any active horizontal smoothing when grounded
wall_jump_smoothing_active = false
elif wall_normal != Vector3.ZERO and not wall_jump_locked:
if wall_jump_count < max_wall_jumps:
wall_jump_count += 1
velocity.y = wall_jump_boost
var incoming = Vector3(velocity.x - 900, 0, velocity.z)
if incoming.length() < 0.01:
incoming = -transform.basis.z
incoming.y = 0
var incoming_dir = incoming
var bounce = incoming_dir - 2.0 * incoming_dir.dot(wall_normal) * wall_normal
if bounce.length() < 0.01:
bounce = -transform.basis.z
bounce.y = 0
var target_hx = bounce.x * wall_jump_push * wall_jump_power_scale
var target_hz = bounce.z * wall_jump_push * wall_jump_power_scale
wall_jump_target.x = target_hx
wall_jump_target.y = 0.0
wall_jump_target.z = target_hz
wall_jump_smoothing_active = true
if jump:
jump.play()
if wall_jump_count >= max_wall_jumps:
wall_jump_locked = true
wall_jump_timer = wall_jump_cooldown
# --- WALL-JUMP SMOOTHING (per-frame) ---
if wall_jump_smoothing_active:
var t = clamp(wall_jump_lerp_speed * delta, 0.0, 1.0)
velocity.x = lerp(velocity.x, wall_jump_target.x, t)
velocity.z = lerp(velocity.z, wall_jump_target.z, t)
if abs(velocity.x - wall_jump_target.x) < wall_jump_smoothing_eps and abs(velocity.z - wall_jump_target.z) < wall_jump_smoothing_eps:
velocity.x = wall_jump_target.x
velocity.z = wall_jump_target.z
wall_jump_smoothing_active = false
# MOVE
move_and_slide()
_check_wall()
# --- AIRTIME / LANDING DEBOUNCE HANDLING (timer-based) ---
# update air_time
if not is_really_on_floor():
air_time += delta
# landing: only when we were previously considered not-on-floor AND now on floor
if is_really_on_floor():
if not was_on_floor:
if air_time >= min_air_time_for_landing and land_cooldown_timer <= 0.0 and not sliding:
if velocity.y < -20:
if superland:
superland.play()
shake_time = 1
shake_strength = 0.15
else:
land.play()
jumping = false
superjumpp = false
wall_jump_count = 0
wall_jump_locked = false
wall_jump_timer = 0.0
land_cooldown_timer = land_cooldown
air_time = 0.0
else:
air_time = 0.0
# update was_on_floor for next frame
was_on_floor = is_really_on_floor()
# camera shake (apply offset on top of smoothed cam_base_y)
if shake_time > 0:
shake_time -= delta
var offset = Vector3(
randf_range(-shake_strength, shake_strength),
randf_range(-shake_strength, shake_strength),
0
)
camera.position = Vector3(0, cam_base_y, 0) + offset
else:
camera.position = Vector3(0, cam_base_y, 0)
func _shoot():
animator.play("shoot")
var bullet = bullet_scene.instantiate()
gunshot.play()
if raycast:
bullet.global_transform = raycast.global_transform
else:
var t = camera.global_transform
var forward = -t.basis.z
bullet.global_transform = Transform3D(t.basis, t.origin + forward)
get_parent().add_child(bullet)
if bullet.has_node("RayCast3D"):
var bullet_raycast = bullet.get_node("RayCast3D")
bullet_raycast.enabled = true
func _start_crouch():
is_crouching = true
target_height = crouch_height
target_cam_y = crouch_height * 0.75
func _stop_crouch():
is_crouching = false
target_height = normal_height
target_cam_y = normal_height * 0.75
func _slam_down():
if velocity.y > -slam_velocity:
velocity.y = -slam_velocity
jumping = false
superjumpp = false
sliding = false
if superland:
superland.play()
func _check_wall():
wall_normal = Vector3.ZERO
for i in range(get_slide_collision_count()):
var collision = get_slide_collision(i)
var normal = collision.get_normal()
if abs(normal.y) < 0.1:
wall_normal = normal
break
all the sounds are good, i tried reimporting, etc etc etc
and if you smell some chatgpt in the code thats because i was so tired that i had to use chatgpt as a last resort
like you know in parkour games where you like
walk and crouch at the same time and you SLIDE
..like in ULTRAKILL?
fortnite?
slide as in FUNCTION, not animation
it’s just FPS right now so im not sure why i’d add an animation..
and also i DID check for any issues with any AudioStreamPlayer3D, etc etc,
NOTHING is wrong
sound file is great
and yes im okay im just going insane from this bug ;-;
also F.Y.I i made some other changes AFTER i posted this question so this isnt the same code as when i was having the trouble in the first place
Is your slide audio node near to your player’s camera? Since the audio is in 3D world it would be hard to hear.If it’s in current place then check every animations
Maybe it sends the audio flying in the sky?
Then if it’s alll good then just
Do this:
if sliding:
walk.stop()
run.stop()
if not slide.playing:
slide.play()
print("Slide wasn't playing,so now I am printing")
If it doesn’t print that line means your slide is silently playing…
Also can you just comment/remove this piece of code:
if is_crouching and running:
slide.play()
else:
slide.stop()
Mh, your slide.play() calls are deep in spaghetti 
I’d go with what @Frozen_Fried said and add some prints to where your slide.play() is called and figure out, which one is canceling the other out. I bet one of those is triggering where it should not.
okay i’ll remove that piece of code, and YES i did try adding debugs, i added a whole sanity check aswell where it’d print if there WAS the slide, and plays it directly in func ready_
and also im not sure how it’d be far away, as it’s parented to the player’s character aswell (and all OTHER sounds work fine)
and i ALMOST forgot, there IS another bug with the sliding function
it collides with the land audio fix and whenever i slide, it just
drags me up and down like im dragged onto a really really REALLY bumpy road
i think you’d be able to see in the function if_really_is_on_ground() ?
Can you just play the slide only once?
You played it 3 times…