simple transform animation
This commit is contained in:
parent
badc59c239
commit
e17c712ec6
4 changed files with 35 additions and 1 deletions
20
src/animation/transform.rs
Normal file
20
src/animation/transform.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue