laundmo / bevy-spatial

Spatial datastructures for Bevy
Other
150 stars 17 forks source link

Cannot run examples #1

Closed ashirviskas closed 2 years ago

ashirviskas commented 2 years ago

Hi there! I'm quite fresh to rust and tried to use provided example code, but it does not compile and gives me the errors below. It might be a quick fix, but I'm totally lost and would if you could provide some guidance. Thank you!

error[E0432]: unresolved imports `bevy_spatial::KDTreeAccess2D`, `bevy_spatial::KDTreePlugin2D`
 --> src/main.rs:6:20
  |
6 | use bevy_spatial::{KDTreeAccess2D, KDTreePlugin2D, SpatialAccess};
  |                    ^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^ no `KDTreePlugin2D` in the root
  |                    |
  |                    no `KDTreeAccess2D` in the root

error[E0277]: the trait bound `for<'r, 's, 't0, 't1, 't2, 't3, 't4> fn(bevy::prelude::Commands<'r, 's>, bevy::prelude::Res<'t0, bevy::prelude::Windows>, bevy::prelude::Res<'t1, [type error]>, bevy::prelude::Query<'t2, 't3, &'t4 mut bevy::prelude::Transform, bevy::prelude::With<Cursor>>) {mouse}: IntoSystem<(), (), _>` is not satisfied
   --> src/main.rs:24:21
    |
24  |         .add_system(mouse)
    |          ---------- ^^^^^ the trait `IntoSystem<(), (), _>` is not implemented for `for<'r, 's, 't0, 't1, 't2, 't3, 't4> fn(bevy::prelude::Commands<'r, 's>, bevy::prelude::Res<'t0, bevy::prelude::Windows>, bevy::prelude::Res<'t1, [type error]>, bevy::prelude::Query<'t2, 't3, &'t4 mut bevy::prelude::Transform, bevy::prelude::With<Cursor>>) {mouse}`
    |          |
    |          required by a bound introduced by this call
    |
    = help: the following other types implement trait `IntoSystemDescriptor<Params>`:
              ExclusiveSystemCoerced
              ExclusiveSystemDescriptor
              ExclusiveSystemFn<F>
              ParallelSystemDescriptor
              SystemDescriptor
              std::boxed::Box<(dyn bevy::prelude::System<Out = (), In = ()> + 'static)>
    = note: required because of the requirements on the impl of `IntoSystemDescriptor<_>` for `for<'r, 's, 't0, 't1, 't2, 't3, 't4> fn(bevy::prelude::Commands<'r, 's>, bevy::prelude::Res<'t0, bevy::prelude::Windows>, bevy::prelude::Res<'t1, [type error]>, bevy::prelude::Query<'t2, 't3, &'t4 mut bevy::prelude::Transform, bevy::prelude::With<Cursor>>) {mouse}`
note: required by a bound in `bevy::prelude::App::add_system`
   --> /home/mati/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.7.0/src/app.rs:325:55
    |
325 |     pub fn add_system<Params>(&mut self, system: impl IntoSystemDescriptor<Params>) -> &mut Self {
    |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `bevy::prelude::App::add_system`

error[E0277]: the trait bound `for<'r, 's, 't0, 't1, 't2> fn(bevy::prelude::Res<'r, bevy::prelude::Windows>, bevy::prelude::Res<'s, [type error]>, bevy::prelude::Query<'t0, 't1, &'t2 mut bevy::prelude::Sprite, bevy::prelude::With<NearestNeighbourComponent>>) {color}: IntoSystem<(), (), _>` is not satisfied
   --> src/main.rs:25:21
    |
25  |         .add_system(color)
    |          ---------- ^^^^^ the trait `IntoSystem<(), (), _>` is not implemented for `for<'r, 's, 't0, 't1, 't2> fn(bevy::prelude::Res<'r, bevy::prelude::Windows>, bevy::prelude::Res<'s, [type error]>, bevy::prelude::Query<'t0, 't1, &'t2 mut bevy::prelude::Sprite, bevy::prelude::With<NearestNeighbourComponent>>) {color}`
    |          |
    |          required by a bound introduced by this call
    |
    = help: the following other types implement trait `IntoSystemDescriptor<Params>`:
              ExclusiveSystemCoerced
              ExclusiveSystemDescriptor
              ExclusiveSystemFn<F>
              ParallelSystemDescriptor
              SystemDescriptor
              std::boxed::Box<(dyn bevy::prelude::System<Out = (), In = ()> + 'static)>
    = note: required because of the requirements on the impl of `IntoSystemDescriptor<_>` for `for<'r, 's, 't0, 't1, 't2> fn(bevy::prelude::Res<'r, bevy::prelude::Windows>, bevy::prelude::Res<'s, [type error]>, bevy::prelude::Query<'t0, 't1, &'t2 mut bevy::prelude::Sprite, bevy::prelude::With<NearestNeighbourComponent>>) {color}`
note: required by a bound in `bevy::prelude::App::add_system`
   --> /home/mati/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.7.0/src/app.rs:325:55
    |
325 |     pub fn add_system<Params>(&mut self, system: impl IntoSystemDescriptor<Params>) -> &mut Self {
    |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `bevy::prelude::App::add_system`

error[E0277]: the trait bound `for<'r, 's, 't0, 't1, 't2> fn(bevy::prelude::Res<'r, bevy::prelude::Windows>, bevy::prelude::Res<'s, [type error]>, bevy::prelude::Query<'t0, 't1, &'t2 mut bevy::prelude::Sprite, bevy::prelude::With<NearestNeighbourComponent>>) {color}: AsSystemLabel<_>` is not satisfied
   --> src/main.rs:26:40
    |
26  |         .add_system(reset_color.before(color))
    |                                 ------ ^^^^^ the trait `AsSystemLabel<_>` is not implemented for `for<'r, 's, 't0, 't1, 't2> fn(bevy::prelude::Res<'r, bevy::prelude::Windows>, bevy::prelude::Res<'s, [type error]>, bevy::prelude::Query<'t0, 't1, &'t2 mut bevy::prelude::Sprite, bevy::prelude::With<NearestNeighbourComponent>>) {color}`
    |                                 |
    |                                 required by a bound introduced by this call
    |
note: required by a bound in `bevy::prelude::ParallelSystemDescriptorCoercion::before`
   --> /home/mati/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.7.0/src/schedule/system_descriptor.rs:132:41
    |
132 |     fn before<Marker>(self, label: impl AsSystemLabel<Marker>) -> ParallelSystemDescriptor;
    |                                         ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `bevy::prelude::ParallelSystemDescriptorCoercion::before`

warning: unused import: `SpatialAccess`
 --> src/main.rs:6:52
  |
6 | use bevy_spatial::{KDTreeAccess2D, KDTreePlugin2D, SpatialAccess};
  |                                                    ^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Some errors have detailed explanations: E0277, E0432.
For more information about an error, try `rustc --explain E0277`.
warning: `virus_game_rust` (bin "virus_game_rust") generated 1 warning
error: could not compile `virus_game_rust` due to 4 previous errors; 1 warning emitted
laundmo commented 2 years ago

Seems to me like you're missing the feature flag (which i should clarify to be fair.)

cargo run --features kdtree --example distance2d