use std::{f32::consts::TAU, num::Wrapping, time::Duration}; use bevy::prelude::*; use bevy_mod_outline::*; #[bevy_main] fn main() { App::new() .insert_resource(ClearColor(Color::BLACK)) .add_plugins((DefaultPlugins, OutlinePlugin)) .add_systems(Startup, setup) .add_systems(Update, (spawn_objects, move_objects, despawn_objects)) .run(); } #[derive(Resource)] struct MyAssets { mesh: Handle, material: Handle, } #[derive(Component)] struct FlyingObject; fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { commands.insert_resource(MyAssets { mesh: meshes.add( Capsule3d::new(1.0, 2.0) .mesh() .rings(10) .latitudes(15) .longitudes(15) .build(), ), material: materials.add(StandardMaterial::from(Color::srgb(0.5, 0.5, 0.5))), }); // Add light source and camera commands.spawn(DirectionalLight { illuminance: 750.0, ..default() }); commands.spawn(( Camera3d::default(), Transform::from_xyz(0.0, 0.0, 50.0).looking_at(Vec3::ZERO, Vec3::Y), Msaa::Sample4, )); } struct SpawnState(Timer, Wrapping); impl Default for SpawnState { fn default() -> Self { let mut timer = Timer::from_seconds(0.75, TimerMode::Repeating); timer.tick(timer.duration() - Duration::from_nanos(1)); Self(timer, Wrapping(0)) } } fn spawn_objects( mut commands: Commands, mut timer: Local, time: Res