--- name: bevy-tweening description: "Bevy ECS skill for tween and juice. Keywords: Bevy, tween, juice, curve, ECS." --- # Bevy tweening ## When to use Load this when a value should ease over time. A tween player is yours to build in ECS from elapsed time. ## ECS shape - **Feature:** `EasingCurve` samples an ease between two values. It is not a player that stores entity state. - **Components:** a tween you own: start, end, elapsed, and duration. - **Systems:** step elapsed time on `Update` with `Time::delta_secs`, then write `Transform`. - **Animation:** property animation over a clip is `AnimationClip` on bevy-animation. That is a clip, not a one-shot UI tween. ```toml [dependencies] bevy = "0.20" ``` One system advances elapsed time. The eased `t` is `EasingCurve::sample_clamped`. Finished tweens are despawned by the marker, not by a callback type. ```rust use bevy::curve::Curve; use bevy::curve::easing::{EaseFunction, EasingCurve}; #[derive(Component)] struct Slide { start: Vec3, end: Vec3, elapsed: f32, duration: f32, } fn spawn_slide(mut commands: Commands) { commands.spawn(( Transform::from_translation(Vec3::ZERO), Slide { start: Vec3::ZERO, end: Vec3::new(2.0, 1.0, 0.0), elapsed: 0.0, duration: 0.6, }, )); } fn step_slides( time: Res