done
This commit is contained in:
@@ -597,6 +597,7 @@ fn spawn_objects(
|
||||
} else {
|
||||
Transform::from_xyz(2.0 * x as f32, 0.5, -2.0 * z as f32)
|
||||
};
|
||||
// Correct Key Card
|
||||
commands
|
||||
.spawn((
|
||||
transform,
|
||||
@@ -627,6 +628,51 @@ fn spawn_objects(
|
||||
Sensor,
|
||||
));
|
||||
});
|
||||
|
||||
// wrong key card
|
||||
let (x, z) = loop {
|
||||
let positions = level.nodes.keys();
|
||||
let random_pos = positions.choose(&mut rand::rng()).unwrap().clone();
|
||||
if random_pos != begin_node && random_pos != end_node {
|
||||
break random_pos;
|
||||
}
|
||||
};
|
||||
let transform = if x <= z {
|
||||
Transform::from_xyz(2.0 * x as f32, 0.5, -2.0 * z as f32)
|
||||
.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians()))
|
||||
} else {
|
||||
Transform::from_xyz(2.0 * x as f32, 0.5, -2.0 * z as f32)
|
||||
};
|
||||
commands
|
||||
.spawn((
|
||||
transform,
|
||||
Interact,
|
||||
PickUpAble,
|
||||
RigidBody::Dynamic,
|
||||
KeyCardId(usize::MAX),
|
||||
Name::new(format!("Id Card {i}")),
|
||||
Visibility::Visible,
|
||||
ItemIcon::new(image_assets.id_card.clone()),
|
||||
SceneRoot(asset.clone()),
|
||||
))
|
||||
.with_children(|parent| {
|
||||
parent.spawn((
|
||||
ColliderMassProperties::Mass(10.0),
|
||||
Collider::cuboid(0.05, 0.05, 0.01),
|
||||
Transform::from_rotation(Quat::from_euler(
|
||||
EulerRot::XYZ,
|
||||
-10.0f32.to_radians(), // X-axis rotation (tilt)
|
||||
-5.0f32.to_radians(), // Y-axis rotation
|
||||
10.0f32.to_radians(), // Z-axis rotation
|
||||
)),
|
||||
));
|
||||
parent.spawn((
|
||||
ActiveEvents::COLLISION_EVENTS,
|
||||
Transform::default(),
|
||||
Collider::ball(0.5), // Interaction radius
|
||||
Sensor,
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user