more asset loader usage
This commit is contained in:
14
src/keys.rs
14
src/keys.rs
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
GameState, billboards::Billboard, player::Player, sounds::PlaySound,
|
||||
squish_animation::SquishAnimation,
|
||||
GameState, billboards::Billboard, loading_assets::GameAssets, player::Player,
|
||||
sounds::PlaySound, squish_animation::SquishAnimation,
|
||||
};
|
||||
use avian3d::prelude::*;
|
||||
use bevy::prelude::*;
|
||||
@@ -21,14 +21,12 @@ pub fn plugin(app: &mut App) {
|
||||
app.add_observer(on_spawn);
|
||||
}
|
||||
|
||||
fn on_spawn(trigger: Trigger<KeySpawn>, mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
fn on_spawn(trigger: Trigger<KeySpawn>, mut commands: Commands, assets: Res<GameAssets>) {
|
||||
let KeySpawn(position, id) = trigger.event();
|
||||
|
||||
let angle = rand::random::<f32>() * PI * 2.;
|
||||
let spawn_dir = Quat::from_rotation_y(angle) * Vec3::new(0.5, 0.6, 0.).normalize();
|
||||
|
||||
let mesh = asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/key.glb"));
|
||||
|
||||
commands
|
||||
.spawn((
|
||||
Name::new("key"),
|
||||
@@ -41,7 +39,11 @@ fn on_spawn(trigger: Trigger<KeySpawn>, mut commands: Commands, asset_server: Re
|
||||
RigidBody::Dynamic,
|
||||
Restitution::new(0.6),
|
||||
))
|
||||
.with_child((Billboard, SquishAnimation(2.6), SceneRoot(mesh)));
|
||||
.with_child((
|
||||
Billboard,
|
||||
SquishAnimation(2.6),
|
||||
SceneRoot(assets.mesh_key.clone()),
|
||||
));
|
||||
}
|
||||
|
||||
fn collect_key(
|
||||
|
||||
Reference in New Issue
Block a user