use new spawn api
This commit is contained in:
29
src/keys.rs
29
src/keys.rs
@@ -28,24 +28,23 @@ fn on_spawn_key(trigger: Trigger<KeySpawn>, mut commands: Commands, assets: Res<
|
||||
let angle = rand::random::<f32>() * PI * 2.;
|
||||
let spawn_dir = Quat::from_rotation_y(angle) * Vec3::new(0.5, 0.6, 0.).normalize();
|
||||
|
||||
commands
|
||||
.spawn((
|
||||
Name::new("key"),
|
||||
Key(id.clone()),
|
||||
Transform::from_translation(*position),
|
||||
Visibility::default(),
|
||||
Collider::sphere(1.5),
|
||||
ExternalImpulse::new(spawn_dir * 180.).with_persistence(false),
|
||||
LockedAxes::ROTATION_LOCKED,
|
||||
RigidBody::Dynamic,
|
||||
CollisionEventsEnabled,
|
||||
Restitution::new(0.6),
|
||||
))
|
||||
.with_child((
|
||||
commands.spawn((
|
||||
Name::new("key"),
|
||||
Key(id.clone()),
|
||||
Transform::from_translation(*position),
|
||||
Visibility::default(),
|
||||
Collider::sphere(1.5),
|
||||
ExternalImpulse::new(spawn_dir * 180.).with_persistence(false),
|
||||
LockedAxes::ROTATION_LOCKED,
|
||||
RigidBody::Dynamic,
|
||||
CollisionEventsEnabled,
|
||||
Restitution::new(0.6),
|
||||
Children::spawn(Spawn((
|
||||
Billboard,
|
||||
SquishAnimation(2.6),
|
||||
SceneRoot(assets.mesh_key.clone()),
|
||||
));
|
||||
))),
|
||||
));
|
||||
}
|
||||
|
||||
fn collect_key(
|
||||
|
||||
Reference in New Issue
Block a user