diff --git a/src/alien.rs b/src/alien.rs index 7614bae..4e73b34 100644 --- a/src/alien.rs +++ b/src/alien.rs @@ -1,8 +1,8 @@ +use avian3d::prelude::*; +use bevy::prelude::*; use std::time::Duration; -use bevy::prelude::*; - -const FOX_PATH: &str = "models/alien_naked.glb"; +const ASSET_PATH: &str = "models/alien_naked.glb"; #[derive(Resource)] struct Animations { @@ -22,8 +22,8 @@ fn setup( ) { // Build the animation graph let (graph, node_indices) = AnimationGraph::from_clips([ - asset_server.load(GltfAssetLabel::Animation(1).from_asset(FOX_PATH)), - asset_server.load(GltfAssetLabel::Animation(0).from_asset(FOX_PATH)), + asset_server.load(GltfAssetLabel::Animation(1).from_asset(ASSET_PATH)), + asset_server.load(GltfAssetLabel::Animation(0).from_asset(ASSET_PATH)), ]); // Insert a resource with the current scene information @@ -33,12 +33,17 @@ fn setup( graph: graph_handle, }); - // Fox commands - .spawn(SceneRoot( - asset_server.load(GltfAssetLabel::Scene(0).from_asset(FOX_PATH)), + .spawn(( + RigidBody::Dynamic, + Collider::capsule(0.2, 1.), + LockedAxes::new().lock_rotation_z().lock_rotation_x(), + Name::from("Alien"), )) - .insert(Name::from("Alien")); + .with_child(( + Transform::from_translation(Vec3::new(0., -0.6, 0.)), + SceneRoot(asset_server.load(GltfAssetLabel::Scene(0).from_asset(ASSET_PATH))), + )); } fn setup_once_loaded( diff --git a/src/main.rs b/src/main.rs index b30fbe4..f157b07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,6 +72,7 @@ fn main() { })); app.add_plugins(PhysicsPlugins::default()); + app.add_plugins(PhysicsDebugPlugin::default()); // bevy_flycam setup so we can get a closer look at the scene, mainly for debugging app.add_plugins(PlayerPlugin);