Trouv / bevy_ecs_ldtk

ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap
Other
641 stars 73 forks source link

Default github example throws error #179

Closed adrylain closed 1 year ago

adrylain commented 1 year ago

The problem seems to be with Bevy's handle struct.

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn(Camera2dBundle::default());

    commands.spawn(LdtkWorldBundle {
        ldtk_handle: asset_server.load("myproject.ldtk"),
        ..Default::default()
    });
}

This error is given:

error[E0308]: mismatched types --> src/main.rs:18:22 18 ldtk_handle: asset_server.load("my_project.ldtk"), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct bevy_asset::handle::Handle, found struct bevy::prelude::Handle
= note: struct `bevy::prelude::Handle` and struct `bevy_asset::handle::Handle` have similar names, but are actually distinct types

note: struct bevy::prelude::Handle is defined in crate bevy_asset --> /home/~/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_asset-0.10.0/src/handle.rs:107:1

Without modification, both the version on the Readme and in the examples folder break in the same way. I have a file called "myproject.ldtk" in the path as well, but its clear that isn't the issue.

Trouv commented 1 year ago

As I mentioned on discord - it kinda looks like a dependency versioning issue issue. bevy 0.10.1 depends on bevy_asset 0.10.1 not bevy_asset 0.10.0. I suppose you could be using bevy 0.10.0 instead, but this error makes me think you're on 0.10.1. You can tell by looking at your Cargo.lock, you might see two entries for bevy_asset in there at two different versions which would be the problem.

Try rm Cargo.lock && cargo clean && cargo update to completely regenerate/rebuild everything from scratch, and if that doesn't help, could you post the contents of your Cargo.toml here?

adrylain commented 1 year ago

I found that I was running bevy 1.10.0. I tried the commands and then switched it to bevy 1.10.1 in the dependencies. The same error persists. Here are my dependencies in my Cargo.toml:

[dependencies] bevy = "0.10.1" bevy_ecs_ldtk = "0.5.0" rand = "0.7.3"

Trouv commented 1 year ago

Ah, bevy_ecs_ldtk only has bevy 0.10 support on 0.6, not 0.5

Trouv commented 1 year ago

bevy_ecs_ldtk is now on 0.7, not 0.5/0.6, try updating your Cargo.toml accordingly and let me know if it resolves your problem.

adrylain commented 1 year ago

It seems like it is now fixed by updating to 0.7.