enemies spawn with heads
This commit is contained in:
@@ -83,7 +83,9 @@ pub struct MoveTarget {
|
||||
#[require(Transform)]
|
||||
#[component(on_add = Self::on_add)]
|
||||
#[model({ "path": "models/alien_naked.glb" })]
|
||||
pub struct EnemySpawn {}
|
||||
pub struct EnemySpawn {
|
||||
pub head: String,
|
||||
}
|
||||
|
||||
impl EnemySpawn {
|
||||
fn on_add(mut world: DeferredWorld, entity: Entity, _id: ComponentId) {
|
||||
@@ -91,8 +93,13 @@ impl EnemySpawn {
|
||||
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 head_mesh = asset_server
|
||||
.load(GltfAssetLabel::Scene(0).from_asset(format!("models/heads/{}.glb", this.head)));
|
||||
|
||||
world
|
||||
.commands()
|
||||
.entity(entity)
|
||||
@@ -106,6 +113,10 @@ impl EnemySpawn {
|
||||
LockedAxes::new().lock_rotation_z().lock_rotation_x(),
|
||||
Transform::from_translation(Vec3::new(0., 1.0, 0.)),
|
||||
))
|
||||
.with_child((
|
||||
Transform::from_translation(Vec3::new(0., 1., 0.)),
|
||||
SceneRoot(head_mesh),
|
||||
))
|
||||
.with_child((
|
||||
Visibility::default(),
|
||||
Transform::from_translation(Vec3::new(0., -1.4, 0.))
|
||||
|
||||
Reference in New Issue
Block a user