make alien a collider

This commit is contained in:
2025-03-03 21:21:59 +01:00
parent 50f279eb8a
commit 4f4cc1ee27
2 changed files with 15 additions and 9 deletions

View File

@@ -1,8 +1,8 @@
use avian3d::prelude::*;
use bevy::prelude::*;
use std::time::Duration; use std::time::Duration;
use bevy::prelude::*; const ASSET_PATH: &str = "models/alien_naked.glb";
const FOX_PATH: &str = "models/alien_naked.glb";
#[derive(Resource)] #[derive(Resource)]
struct Animations { struct Animations {
@@ -22,8 +22,8 @@ fn setup(
) { ) {
// Build the animation graph // Build the animation graph
let (graph, node_indices) = AnimationGraph::from_clips([ let (graph, node_indices) = AnimationGraph::from_clips([
asset_server.load(GltfAssetLabel::Animation(1).from_asset(FOX_PATH)), asset_server.load(GltfAssetLabel::Animation(1).from_asset(ASSET_PATH)),
asset_server.load(GltfAssetLabel::Animation(0).from_asset(FOX_PATH)), asset_server.load(GltfAssetLabel::Animation(0).from_asset(ASSET_PATH)),
]); ]);
// Insert a resource with the current scene information // Insert a resource with the current scene information
@@ -33,12 +33,17 @@ fn setup(
graph: graph_handle, graph: graph_handle,
}); });
// Fox
commands commands
.spawn(SceneRoot( .spawn((
asset_server.load(GltfAssetLabel::Scene(0).from_asset(FOX_PATH)), 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( fn setup_once_loaded(

View File

@@ -72,6 +72,7 @@ fn main() {
})); }));
app.add_plugins(PhysicsPlugins::default()); 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 // bevy_flycam setup so we can get a closer look at the scene, mainly for debugging
app.add_plugins(PlayerPlugin); app.add_plugins(PlayerPlugin);