cube hopping

This commit is contained in:
Jim 2025-08-24 15:02:50 -04:00
parent 1a65fad218
commit 928faf9570
Signed by: jim
GPG key ID: 3236D2F059A7C0AC
4 changed files with 26 additions and 18 deletions

View file

@ -16,11 +16,11 @@
MouseButton(Middle): [
CameraOrbitEnable,
],
KeyCode(Escape): [
TogglePause,
],
MouseButton(Left): [
CameraPanEnable,
],
KeyCode(Escape): [
TogglePause,
],
},
)

View file

@ -40,7 +40,8 @@ fn setup(
// Dynamic physics object with a collision shape and initial angular velocity
for y in 5..15 {
commands.spawn((
commands
.spawn((
RigidBody::Dynamic,
Collider::cuboid(1.0, 1.0, 1.0),
AngularVelocity(Vec3::new(2.5, 3.5, 1.5)),
@ -52,7 +53,14 @@ fn setup(
..default()
})),
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

View file

@ -9,6 +9,6 @@ pub struct PhysicsPlugin;
impl Plugin for PhysicsPlugin {
fn build(&self, app: &mut App) {
app.add_plugins(PhysicsPlugins::default());
app.add_plugins((PhysicsPlugins::default(), PhysicsPickingPlugin));
}
}