cube hopping
This commit is contained in:
parent
1a65fad218
commit
928faf9570
4 changed files with 26 additions and 18 deletions
|
|
@ -16,11 +16,11 @@
|
||||||
MouseButton(Middle): [
|
MouseButton(Middle): [
|
||||||
CameraOrbitEnable,
|
CameraOrbitEnable,
|
||||||
],
|
],
|
||||||
KeyCode(Escape): [
|
|
||||||
TogglePause,
|
|
||||||
],
|
|
||||||
MouseButton(Left): [
|
MouseButton(Left): [
|
||||||
CameraPanEnable,
|
CameraPanEnable,
|
||||||
],
|
],
|
||||||
|
KeyCode(Escape): [
|
||||||
|
TogglePause,
|
||||||
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -40,19 +40,27 @@ fn setup(
|
||||||
|
|
||||||
// Dynamic physics object with a collision shape and initial angular velocity
|
// Dynamic physics object with a collision shape and initial angular velocity
|
||||||
for y in 5..15 {
|
for y in 5..15 {
|
||||||
commands.spawn((
|
commands
|
||||||
RigidBody::Dynamic,
|
.spawn((
|
||||||
Collider::cuboid(1.0, 1.0, 1.0),
|
RigidBody::Dynamic,
|
||||||
AngularVelocity(Vec3::new(2.5, 3.5, 1.5)),
|
Collider::cuboid(1.0, 1.0, 1.0),
|
||||||
Mesh3d(meshes.add(Cuboid::from_length(1.0))),
|
AngularVelocity(Vec3::new(2.5, 3.5, 1.5)),
|
||||||
MeshMaterial3d(materials.add(StandardMaterial {
|
Mesh3d(meshes.add(Cuboid::from_length(1.0))),
|
||||||
base_color: Color::srgb_u8(220, 156, 86),
|
MeshMaterial3d(materials.add(StandardMaterial {
|
||||||
metallic: 1.0,
|
base_color: Color::srgb_u8(220, 156, 86),
|
||||||
perceptual_roughness: 0.3,
|
metallic: 1.0,
|
||||||
..default()
|
perceptual_roughness: 0.3,
|
||||||
})),
|
..default()
|
||||||
Transform::from_xyz(0.0, y as f32 * 1.1, 0.0),
|
})),
|
||||||
));
|
Transform::from_xyz(0.0, y as f32 * 1.1, 0.0),
|
||||||
|
))
|
||||||
|
.observe(
|
||||||
|
|trigger: Trigger<Pointer<Click>>, mut query: Query<&mut LinearVelocity>| {
|
||||||
|
if let Ok(mut v) = query.get_mut(trigger.target()) {
|
||||||
|
v.y += 3.0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Light
|
// Light
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,6 @@ pub struct PhysicsPlugin;
|
||||||
|
|
||||||
impl Plugin for PhysicsPlugin {
|
impl Plugin for PhysicsPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_plugins(PhysicsPlugins::default());
|
app.add_plugins((PhysicsPlugins::default(), PhysicsPickingPlugin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue