Skip to content

Commit 3dc7b68

Browse files
committed
Fix #1704 (#1705)
So I think that the underlying issue is actually a system order ambiguity thing between `spawn_bonus` and `rotate_bonus`, but I'm not confident enough about `run_criteria`, `FixedTimeStep`, etc. to sort that out.
1 parent cd8025d commit 3dc7b68

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

examples/game/alien_cake_addict.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,12 @@ fn spawn_bonus(
330330
// let the cake turn on itself
331331
fn rotate_bonus(game: Res<Game>, time: Res<Time>, mut transforms: Query<&mut Transform>) {
332332
if let Some(entity) = game.bonus.entity {
333-
let mut cake_transform = transforms.get_mut(entity).unwrap();
334-
cake_transform.rotate(Quat::from_rotation_y(time.delta_seconds()));
335-
cake_transform.scale = Vec3::splat(
336-
1.0 + (game.score as f32 / 10.0 * time.seconds_since_startup().sin() as f32).abs(),
337-
);
333+
if let Ok(mut cake_transform) = transforms.get_mut(entity) {
334+
cake_transform.rotate(Quat::from_rotation_y(time.delta_seconds()));
335+
cake_transform.scale = Vec3::splat(
336+
1.0 + (game.score as f32 / 10.0 * time.seconds_since_startup().sin() as f32).abs(),
337+
);
338+
}
338339
}
339340
}
340341

0 commit comments

Comments
 (0)