new character format
This commit is contained in:
@@ -117,11 +117,8 @@ pub struct EnemySpawn {
|
||||
|
||||
impl EnemySpawn {
|
||||
fn on_add(mut world: DeferredWorld, entity: Entity, _id: ComponentId) {
|
||||
let Some(asset_server) = world.get_resource::<AssetServer>() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(assets) = world.get_resource::<GameAssets>() else {
|
||||
//TODO: figure out why this crashes if removed
|
||||
let Some(_assets) = world.get_resource::<GameAssets>() else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -135,38 +132,17 @@ impl EnemySpawn {
|
||||
let mut this_transform = *this_transform;
|
||||
this_transform.translation += Vec3::new(0., 1., 0.);
|
||||
|
||||
let mesh = assets.mesh_alien.clone();
|
||||
|
||||
let head_mesh = asset_server
|
||||
.load(GltfAssetLabel::Scene(0).from_asset(format!("models/heads/{}.glb", this.head)));
|
||||
|
||||
let head = this.head.clone();
|
||||
|
||||
world
|
||||
.commands()
|
||||
.entity(entity)
|
||||
.insert((
|
||||
this_transform,
|
||||
Name::from(format!("enemy [{}]", head)),
|
||||
Visibility::default(),
|
||||
RigidBody::Dynamic,
|
||||
Collider::capsule(0.4, 2.),
|
||||
CollisionLayers::new(LayerMask(GameLayer::Npc.to_bits()), LayerMask::ALL),
|
||||
LockedAxes::new().lock_rotation_z().lock_rotation_x(),
|
||||
))
|
||||
.with_children(|parent| {
|
||||
parent
|
||||
.spawn((
|
||||
Transform::from_translation(Vec3::new(0., 1., 0.)),
|
||||
SceneRoot(head_mesh),
|
||||
))
|
||||
.with_child((
|
||||
Visibility::default(),
|
||||
Transform::from_translation(Vec3::new(0., -2.4, 0.))
|
||||
.with_scale(Vec3::splat(1.5)),
|
||||
SceneRoot(mesh),
|
||||
));
|
||||
});
|
||||
world.commands().entity(entity).insert((
|
||||
this_transform,
|
||||
Name::from(format!("enemy [{}]", head)),
|
||||
Visibility::default(),
|
||||
RigidBody::Dynamic,
|
||||
Collider::capsule(0.4, 2.),
|
||||
CollisionLayers::new(LayerMask(GameLayer::Npc.to_bits()), LayerMask::ALL),
|
||||
LockedAxes::new().lock_rotation_z().lock_rotation_x(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user