From 8508ca16a48588ca9e7a730d4bbd906cb7366f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20N=C3=A4=C3=A4s?= Date: Tue, 15 Oct 2024 21:26:50 +0200 Subject: [PATCH] clean up and better description --- examples/ribbon.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/ribbon.rs b/examples/ribbon.rs index 4cf02841..1317d620 100644 --- a/examples/ribbon.rs +++ b/examples/ribbon.rs @@ -1,4 +1,8 @@ -//! Draws a trail and connects the trails using a ribbon. +//! Uses the [RibbonModifier] to draw a "tracer" or a "trail" following an Entity. +//! The trail effect is achieved by using the [CloneModifier] on the "head" particle in combination +//! with the [RibbonModifier]. +//! The movement of the head particle is achieved by linking the particle position to a CPU position using a [Property] in [move_head]. +//! use bevy::color::palettes::css::YELLOW; use bevy::math::vec4; @@ -17,7 +21,7 @@ use utils::*; const K: f32 = 0.64; const L: f32 = 0.384; -const TIME_SCALE: f32 = 10.0; +const TIME_SCALE: f32 = 6.5; const SHAPE_SCALE: f32 = 25.0; const LIFETIME: f32 = 1.5; const TRAIL_SPAWN_RATE: f32 = 256.0; @@ -25,7 +29,7 @@ const TRAIL_SPAWN_RATE: f32 = 256.0; fn main() -> Result<(), Box> { let app_exit = utils::make_test_app("ribbon") .add_systems(Startup, setup) - .add_systems(Update, move_particle_effect) + .add_systems(Update, move_head) .run(); app_exit.into_result() } @@ -124,7 +128,7 @@ fn setup(mut commands: Commands, mut effects: ResMut>) { .insert(Name::new("ribbon")); } -fn move_particle_effect( +fn move_head( mut gizmos: Gizmos, mut query: Query<&mut Transform, With>, mut effect: Query<&mut EffectProperties>, @@ -141,7 +145,6 @@ fn move_particle_effect( 0.0, ) * SHAPE_SCALE; - //let pos = vec3(f32::cos(theta), f32::sin(theta), 0.0) * 5.0; properties.set("head_pos", (pos).into()); gizmos.sphere(pos, Quat::IDENTITY, 1.0, YELLOW); transform.translation = pos;