extends CharacterBody2D const SPEED = 300.0 const JUMP_VELOCITY = -400.0 @onready var adaptive_stuffs: AudioStreamPlayer = $Josh var moosic: AudioStreamSynchronized var drum_vol: float = -13.17 func _ready() -> void: if adaptive_stuffs.stream is AudioStreamSynchronized: moosic = adaptive_stuffs.stream as AudioStreamSynchronized print_debug("Dis oki") moosic.set_sync_stream_volume(1, -13.17) else: print_debug("Dis not oki") func _physics_process(delta: float) -> void: # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta # Handle jump. if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. var direction := Input.get_axis("ui_left", "ui_right") if direction: velocity.x = direction * SPEED changeVol(1, 0.1) else: velocity.x = move_toward(velocity.x, 0, SPEED) changeVol(1, -0.1) move_and_slide() func changeVol(streamIndex: int, speed: float) -> void: if moosic: drum_vol += speed drum_vol = clampf(drum_vol, -13.17, 0) moosic.set_sync_stream_volume(streamIndex, drum_vol) else: print_debug("The stream is not an AudioStreamSynchronized")
or share this direct link: