class_name Balls extends BallsMultiplayer func _ready() -> void: for ball in bodies.get_children(): _set_ball_physics(ball) setup_multiplayer() func _physics_process(_delta: float) -> void: if not Globals.multiplayer_data.can_do_request_server_only(): return if not balls_moving: if white_ball.linear_velocity.length() == 0.0: return balls_moving = false for ball in bodies.get_children(): if ball.linear_velocity.length() == 0.0: continue balls_moving = true break if not balls_moving: Globals.game_state.balls_stopped_moving.emit() func _on__ball_body_entered(ball: Node) -> void: if not Globals.multiplayer_data.can_do_request_server_only(): return if ball.name == "pool_table": return var speed = ball.linear_velocity.length() var speed_norm = clamp(speed / max_speed, 0.0, 1.0) var volume = remap( speed, min_speed, max_speed, min_volume_db, max_volume_db ) ball_sounds.pitch_scale = lerp(min_pitch, max_pitch, pow(speed_norm, 0.5)) ball_sounds.volume_db = clamp(volume, min_volume_db, max_volume_db) ball_sounds.play()