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 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(