enemies spawn with heads

This commit is contained in:
2025-03-09 21:21:38 +01:00
parent 2a611c9eaa
commit a6a918f842
4 changed files with 17 additions and 2 deletions

View File

@@ -627,7 +627,8 @@
{ {
"classname" "enemy_spawn" "classname" "enemy_spawn"
"origin" "648 -680 -248" "origin" "648 -680 -248"
"angles" "0 -75 0" "angles" "0 -90 0"
"head" "field medic"
} }
// entity 3 // entity 3
{ {
@@ -638,6 +639,8 @@
{ {
"classname" "enemy_spawn" "classname" "enemy_spawn"
"origin" "3256 248 -248" "origin" "3256 248 -248"
"head" "field medic"
"angles" "0 0 0"
} }
// entity 5 // entity 5
{ {

Binary file not shown.

View File

@@ -83,7 +83,9 @@ pub struct MoveTarget {
#[require(Transform)] #[require(Transform)]
#[component(on_add = Self::on_add)] #[component(on_add = Self::on_add)]
#[model({ "path": "models/alien_naked.glb" })] #[model({ "path": "models/alien_naked.glb" })]
pub struct EnemySpawn {} pub struct EnemySpawn {
pub head: String,
}
impl EnemySpawn { impl EnemySpawn {
fn on_add(mut world: DeferredWorld, entity: Entity, _id: ComponentId) { fn on_add(mut world: DeferredWorld, entity: Entity, _id: ComponentId) {
@@ -91,8 +93,13 @@ impl EnemySpawn {
return; return;
}; };
let this = world.get_entity(entity).unwrap().get::<Self>().unwrap();
let mesh = asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/alien_naked.glb")); let mesh = asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/alien_naked.glb"));
let head_mesh = asset_server
.load(GltfAssetLabel::Scene(0).from_asset(format!("models/heads/{}.glb", this.head)));
world world
.commands() .commands()
.entity(entity) .entity(entity)
@@ -106,6 +113,10 @@ impl EnemySpawn {
LockedAxes::new().lock_rotation_z().lock_rotation_x(), LockedAxes::new().lock_rotation_z().lock_rotation_x(),
Transform::from_translation(Vec3::new(0., 1.0, 0.)), Transform::from_translation(Vec3::new(0., 1.0, 0.)),
)) ))
.with_child((
Transform::from_translation(Vec3::new(0., 1., 0.)),
SceneRoot(head_mesh),
))
.with_child(( .with_child((
Visibility::default(), Visibility::default(),
Transform::from_translation(Vec3::new(0., -1.4, 0.)) Transform::from_translation(Vec3::new(0., -1.4, 0.))

View File

@@ -66,6 +66,7 @@
@PointClass base(transform) model({ "path": "models/alien_naked.glb" }) = enemy_spawn @PointClass base(transform) model({ "path": "models/alien_naked.glb" }) = enemy_spawn
[ [
head(string) : "head" : "" : ""
] ]
@SolidClass base(transform, target) = movable @SolidClass base(transform, target) = movable