#Asset not loading for some reason?

31 messages · Page 1 of 1 (latest)

river gate
#

Hello all,

I am trying to follow this tutorial https://www.youtube.com/watch?v=R-u1EY9fOJQ&list=PL2wAo2qwCxGDp9fzBOTy_kpUTSwM1iWWd&index=2

However, I am a bit stuck to why my code does not work?
Here is the gist of it, my workspace is set up to have a parent folder called "mini-games" and then subsequent folders containing different mini-games (see image below)

Currently I only have 1, the one in the tutorial.

In my spaceship.rs file is the following function:

// <--- Systems ---> //
fn spawn_spaceship(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn(SpaceShipBundle {
        velocity: Velocity(START_VELOCITY),
        model: SceneBundle {
            scene: asset_server.load("./Spaceship.glb#Scene0"),
            transform: Transform::from_translation(START_TRANSLATION),
            ..default()
        },
    });
}

The error arrises from the asset_server.load("") line. However, I am not entirely sure why.

When I run the command:

cargo run -p spaceship

Here is the error I get:

called `Result::unwrap()` on an `Err` value: PoisonError { .. }```

When I remove the `#Scene0` (aka the line becomes asset_server.load("./Spaceship.glb"),) I now get this error:

ERROR bevy_asset::server: Could not find an asset loader matching: Loader Name: None; Asset Type: None; Extension: None; Path: Some("./Spaceship.glb");


What could be causing this issue?

Thank you all in advance.

Welcome to 'Bevy Basics: Game Development Essentials in Bevy.'

This episode covers 3D basics, resources, and organizing code!

If you haven't seen the first episode yet, you can find it here:
https://www.youtube.com/watch?v=B6ZFuYYZCSY.

Series Playlist:
https://www.youtube.com/playlist?list=PL2wAo2qwCxGDp9fzBOTy_kpUTSwM1iWWd

You can find th...

▶ Play video
iron vault
#

The error you copy-pasted is not the one that's useful in this case, it just means that some other thread panicked as a cascaded panics (read about mutex poisoning if you wanna read more)

#

You should probably run the app with RUST_BACKTRACE=1 the environment variables, so that you get an actual stack trace when your app crashes

river gate
#

It now works

#

But when the model is loaded, it is completely black

#

When I downgrade to bevy 0.12 it works fine. What gives?

iron vault
#

It's not actually completely black

#

the background is a very dark purple, and the spaceship is all black

river gate
#

The spaceship should look like this

iron vault
#

You probably don't have lights in the scene, that's why it looks all black

iron vault
#

ah wait I didn't see your message about it being fine on 0.12

river gate
#

fn main() {
    App::new()
        // Bevy built-ins.
        .insert_resource(ClearColor(Color::rgb(0.1, 0.0, 0.15)))
        .insert_resource(AmbientLight {
            color: Color::WHITE,
            brightness: 0.75,
        })
        .add_plugins(DefaultPlugins)
        // User defined plugins.
        .add_plugins(MovementPlugin)
        //.add_plugins(DebugPlugin)
        .add_plugins(SpaceshipPlugin)
        .add_plugins(CameraPlugin)
        .run();
}
iron vault
#

Can you copy-paste the first lines of log when you run the app? Particularly one with AdapterInfo

river gate
#

2024-04-06T17:12:33.922765Z INFO bevy_render::renderer: AdapterInfo { name: "Apple M2", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }

#

And this is definitely not a model thing

#

because when I load a different model, its still completely black

iron vault
#

Can you try adding a light anyway? You've probably uncovered a bug with ambient lights on macOS

iron vault
#

Yeah, like a directional light or a point light close to the model

river gate
#

Like so?

        .insert_resource(DirectionalLight {
            color: Color::WHITE,
            illuminance: 400.,
            ..default()
        })
strong nymph
#

Try increasing the brightness by a ton

#

All lighting has gotten 'weaker' in 0.13 compared to 0.12

river gate
#

This is it

#

So dumb 😭

#

Thanks a lot guys