vec2 velocity thank goodness
parent
a5400fafaa
commit
5561191864
|
@ -16,7 +16,7 @@ fn main() {
|
||||||
struct Boid;
|
struct Boid;
|
||||||
|
|
||||||
#[derive(Component, Default)]
|
#[derive(Component, Default)]
|
||||||
struct Velocity(Vec3);
|
struct Velocity(Vec2);
|
||||||
|
|
||||||
#[derive(Bundle, Default)]
|
#[derive(Bundle, Default)]
|
||||||
struct BoidBundle {
|
struct BoidBundle {
|
||||||
|
@ -27,7 +27,7 @@ struct BoidBundle {
|
||||||
|
|
||||||
fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>, time: Res<Time>) {
|
fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>, time: Res<Time>) {
|
||||||
for (mut transform, velocity) in &mut boids {
|
for (mut transform, velocity) in &mut boids {
|
||||||
transform.translation += velocity.0 * time.delta_seconds();
|
transform.translation += velocity.0.extend(0.) * time.delta_seconds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ fn setup(
|
||||||
transform: Transform::from_scale(Vec3::splat(2.5)),
|
transform: Transform::from_scale(Vec3::splat(2.5)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
velocity: Velocity(Vec3::Y * 100.),
|
velocity: Velocity(Vec2::Y * 100.),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue