2

I wanted to try the amethyst_physics library to make a game. (Duh) I followed to Example, but somhow I does not work:

use amethyst::GameDataBuilder;
use amethyst_physics::{PhysicsBundle};
use amethyst_nphysics::NPhysicsBackend;

fn main() -> amethyst::Result<()> {
    amethyst::start_logger(Default::default());

    let game_data = GameDataBuilder::default()
        .with_bundle(
            PhysicsBundle::<f32, NPhysicsBackend>::new()
        )
    ;
    Ok(())
}

Error:

the trait bound `amethyst_physics::PhysicsBundle<'_, '_, f32, amethyst_nphysics::NPhysicsBackend>: amethyst::amethyst_core::SystemBundle<'_, '_>` is not satisfied
the trait `amethyst::amethyst_core::SystemBundle<'_, '_>` is not implemented for `amethyst_physics::PhysicsBundle<'_, '_, f32, amethyst_nphysics::NPhysicsBackend>`

Here is the example.

What am I doing wrong?

Voß
  • 103
  • 9
  • I tried running exact same code including the crate you mentioned. Got lots of "use of undeclared crate or module". It would be a good idea if you add a reproducible example so the readers can try what you are saying. – Mihir Luthra Dec 04 '20 at 15:38
  • @Mihir I have no problem running it, except for the expected error mentioned above. Edit: Well, additionally you have to add the crates to your Cargo.toml – Voß Dec 04 '20 at 15:42
  • How can you run it if it doesn't even compile? – Sven Marnach Dec 04 '20 at 15:44
  • I meant running in terms of that the compilation breaks only at the expected error. My fault. – Voß Dec 04 '20 at 15:45
  • 1
    I got it running locally with the same error. Cargo.toml `amethyst = { version = "0.15.3", features = ["empty"] } amethyst_nphysics = "0.2.0" amethyst_physics = "0.2.0"` – Ibraheem Ahmed Dec 04 '20 at 15:46
  • It is pretty weird because `SystemBundle` *is* implemented for `PhysicsBundle` [here](https://docs.rs/amethyst_physics/0.2.0/src/amethyst_physics/systems/physics_bundle.rs.html#406). It looks like the bounds should be satisfied – Ibraheem Ahmed Dec 04 '20 at 15:48
  • Only if the assoicated lifetimes are `'static`, which apparently isn't the case here. – Sven Marnach Dec 04 '20 at 15:48
  • @SvenMarnach [I did mark the associated lifetimes as `'static`](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=24bac2b28aff3d0c418fb7ef67caa18b) – Ibraheem Ahmed Dec 04 '20 at 15:49
  • Hmm, that's indeed weird. – Sven Marnach Dec 04 '20 at 15:51
  • My only guess is that it is a versioning issue – Ibraheem Ahmed Dec 04 '20 at 15:51

1 Answers1

2

This appears to be a bug. It compiles successfully using amethyst version 0.15.1 but not 0.15.3. A regression like this is not expected during a patch change.

amethyst uses amethyst_core version 0.15.3 (where SystemBundle is defined) but amethyst_physics uses amethyst_core version 0.10.1.

I've filed an issue on the amethyst repository.


Use this as a workaround:

amethyst = { version = ">=0.15.0, <0.15.3", features = ["empty"] } 
kmdreko
  • 42,554
  • 6
  • 57
  • 106
  • This still looks like a compiler bug to me, since it's completely unclear why it fails to compile. – Sven Marnach Dec 04 '20 at 19:47
  • There's many issues already filed on the Rust compiler asking for better diagnostic error messages in situations like this. – kmdreko Dec 04 '20 at 20:21
  • So you think the compiler is right to reject the code, and should just print a better diagnostic? That's possible, though I can't see what's wrong with the code, and to me it looks like the compiler should accept it. – Sven Marnach Dec 07 '20 at 13:25
  • @SvenMarnach Yes, `PhysicsBundle` doesn't implement the `SystemBundle` version that `with_bundle()` expects (when using `amethyst` version 0.15.3). Its the same kind of version compatibility issue as [Why is a trait not implemented for a type that clearly has it implemented?](https://stackoverflow.com/q/44437123) – kmdreko Dec 07 '20 at 17:39