use std::f32; use bevy::{asset::LoadedFolder, prelude::*}; use bevy_synthizer::*; #[derive(Component, Deref, DerefMut)] struct RotationTimer(Timer); impl Default for RotationTimer { fn default() -> Self { Self(Timer::from_seconds(30., TimerMode::Repeating)) } } #[derive(Resource, Default, Deref, DerefMut)] struct AssetHandles(Handle); fn setup(asset_server: Res, mut handles: ResMut) { **handles = asset_server.load_folder("."); } fn load_and_create( mut commands: Commands, asset_server: Res, handles: Res, listeners: Query<&Listener>, ) { if !asset_server.is_loaded_with_dependencies(&**handles) { return; } if !listeners.is_empty() { return; } commands.spawn((Transform::default(), Listener, RotationTimer::default())); let handle = asset_server.load("footstep.wav"); commands.spawn(( Transform::from_translation(Vec3::new(10., 0., 0.)), Source::default(), Sound { audio: handle.into(), looping: true, ..default() }, )); } fn rotate_listener(time: Res