simple transform animation

This commit is contained in:
Rendo 2026-01-25 15:08:16 +05:00
commit e17c712ec6
4 changed files with 35 additions and 1 deletions

View file

@ -0,0 +1,20 @@
use bevy::prelude::*;
#[derive(Component)]
pub struct AnimatedTransform {
pub translation: Vec3,
}
impl AnimatedTransform {
pub fn from_xyz(x: f32, y: f32, z: f32) -> Self {
AnimatedTransform {
translation: Vec3 { x, y, z },
}
}
}
pub fn transform_animation(query: Query<(&mut Transform, &AnimatedTransform)>) {
for (mut transform, anim_transform) in query {
transform.translation = transform.translation.lerp(anim_transform.translation, 0.5);
}
}