use new spawn api
This commit is contained in:
@@ -100,24 +100,22 @@ fn on_trigger_gun(
|
||||
let mut t = Transform::from_translation(state.pos).with_rotation(rotation);
|
||||
t.translation += t.forward().as_vec3() * 2.0;
|
||||
|
||||
commands
|
||||
.spawn((
|
||||
Name::new("projectile-gun"),
|
||||
GunProjectile {
|
||||
time: time.elapsed_secs(),
|
||||
owner_head: state.head,
|
||||
},
|
||||
Collider::capsule_endpoints(0.5, Vec3::new(0., 0., 0.), Vec3::new(0., 0., -3.)),
|
||||
CollisionLayers::new(
|
||||
LayerMask(GameLayer::Projectile.to_bits()),
|
||||
LayerMask(state.target_layer.to_bits() | GameLayer::Level.to_bits()),
|
||||
),
|
||||
Sensor,
|
||||
CollisionEventsEnabled,
|
||||
Visibility::default(),
|
||||
t,
|
||||
))
|
||||
.with_child(Gizmo {
|
||||
commands.spawn((
|
||||
Name::new("projectile-gun"),
|
||||
GunProjectile {
|
||||
time: time.elapsed_secs(),
|
||||
owner_head: state.head,
|
||||
},
|
||||
Collider::capsule_endpoints(0.5, Vec3::new(0., 0., 0.), Vec3::new(0., 0., -3.)),
|
||||
CollisionLayers::new(
|
||||
LayerMask(GameLayer::Projectile.to_bits()),
|
||||
LayerMask(state.target_layer.to_bits() | GameLayer::Level.to_bits()),
|
||||
),
|
||||
Sensor,
|
||||
CollisionEventsEnabled,
|
||||
Visibility::default(),
|
||||
t,
|
||||
Children::spawn(Spawn(Gizmo {
|
||||
handle: gizmo_assets.add({
|
||||
let mut g = GizmoAsset::default();
|
||||
g.line(Vec3::Z * -2., Vec3::Z * 2., LinearRgba::rgb(0.9, 0.9, 0.));
|
||||
@@ -128,7 +126,8 @@ fn on_trigger_gun(
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
});
|
||||
})),
|
||||
));
|
||||
}
|
||||
|
||||
fn update(mut query: Query<&mut Transform, With<GunProjectile>>) {
|
||||
|
||||
@@ -114,39 +114,40 @@ fn on_trigger_missile(
|
||||
let mesh = assets.projectiles["missile.glb"].clone();
|
||||
let asset = gltf_assets.get(&mesh).unwrap();
|
||||
|
||||
commands
|
||||
.spawn((
|
||||
Name::new("projectile-missle"),
|
||||
MissileProjectile {
|
||||
time: time.elapsed_secs(),
|
||||
damage: head.damage,
|
||||
},
|
||||
Collider::capsule_endpoints(0.4, Vec3::new(0., 0., 2.), Vec3::new(0., 0., -2.)),
|
||||
CollisionLayers::new(
|
||||
LayerMask(GameLayer::Projectile.to_bits()),
|
||||
LayerMask(state.target_layer.to_bits() | GameLayer::Level.to_bits()),
|
||||
commands.spawn((
|
||||
Name::new("projectile-missle"),
|
||||
MissileProjectile {
|
||||
time: time.elapsed_secs(),
|
||||
damage: head.damage,
|
||||
},
|
||||
Collider::capsule_endpoints(0.4, Vec3::new(0., 0., 2.), Vec3::new(0., 0., -2.)),
|
||||
CollisionLayers::new(
|
||||
LayerMask(GameLayer::Projectile.to_bits()),
|
||||
LayerMask(state.target_layer.to_bits() | GameLayer::Level.to_bits()),
|
||||
),
|
||||
Sensor,
|
||||
CollisionEventsEnabled,
|
||||
Visibility::default(),
|
||||
t,
|
||||
children![
|
||||
(
|
||||
Transform::from_rotation(Quat::from_rotation_x(PI / 2.).inverse())
|
||||
.with_scale(Vec3::splat(0.04)),
|
||||
SceneRoot(asset.scenes[0].clone()),
|
||||
),
|
||||
Sensor,
|
||||
CollisionEventsEnabled,
|
||||
Visibility::default(),
|
||||
t,
|
||||
))
|
||||
.with_child((
|
||||
Transform::from_rotation(Quat::from_rotation_x(PI / 2.).inverse())
|
||||
.with_scale(Vec3::splat(0.04)),
|
||||
SceneRoot(asset.scenes[0].clone()),
|
||||
))
|
||||
.with_child((
|
||||
Trail::new(t.translation, LinearRgba::rgb(0.9, 0.9, 0.)),
|
||||
Gizmo {
|
||||
handle: gizmo_assets.add(GizmoAsset::default()),
|
||||
line_config: GizmoLineConfig {
|
||||
width: 10.,
|
||||
(
|
||||
Trail::new(t.translation, LinearRgba::rgb(0.9, 0.9, 0.)),
|
||||
Gizmo {
|
||||
handle: gizmo_assets.add(GizmoAsset::default()),
|
||||
line_config: GizmoLineConfig {
|
||||
width: 10.,
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
},
|
||||
));
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
fn update(mut query: Query<&mut Transform, With<MissileProjectile>>) {
|
||||
|
||||
Reference in New Issue
Block a user