use new spawn api

This commit is contained in:
2025-04-29 19:55:40 +02:00
parent 11568d57ed
commit 5cc97da98b
8 changed files with 265 additions and 282 deletions

View File

@@ -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(