diff --git a/examples/actor_with_collider.rs b/examples/actor_with_collider.rs index 48a0c31..29f5481 100644 --- a/examples/actor_with_collider.rs +++ b/examples/actor_with_collider.rs @@ -1,3 +1,6 @@ +//! Shows a minimal example of using `avian_pickup` with Bevy. +//! Here, the actor has a collider as well. + use std::f32::consts::FRAC_PI_2; use avian3d::prelude::*; @@ -26,9 +29,10 @@ fn main() { util::plugin(util::Example::Generic), )) .add_systems(Startup, setup) - // Need to read input and rotate camera before physics, - // this is unfortunately the best way to schedule this: - // + // Input handling and camera movement need to be executed every frame, + // so we run them in a variable timestep. + // We also want them to happen before the physics system, so we add them + // to the last variable timestep schedule before the fixed timestep systems run. .add_systems( RunFixedMainLoop, (handle_input, rotate_camera).before(run_fixed_main_schedule), diff --git a/examples/manipulate_prop.rs b/examples/manipulate_prop.rs index 8b23c05..b14b493 100644 --- a/examples/manipulate_prop.rs +++ b/examples/manipulate_prop.rs @@ -1,3 +1,6 @@ +//! Shows how to move and rotate a prop that is being held. +//! This can be used to implement something like Garry's Mod's physics gun. + use std::f32::consts::FRAC_PI_2; use avian3d::prelude::*; @@ -29,9 +32,10 @@ fn main() { util::plugin(util::Example::Manipulation), )) .add_systems(Startup, setup) - // Need to read input and rotate camera before physics, - // this is unfortunately the best way to schedule this: - // + // Input handling and camera movement need to be executed every frame, + // so we run them in a variable timestep. + // We also want them to happen before the physics system, so we add them + // to the last variable timestep schedule before the fixed timestep systems run. .add_systems( RunFixedMainLoop, (accumulate_input, handle_pickup_input, rotate_camera) @@ -60,6 +64,8 @@ fn setup( // Add this to set up the camera as the entity that can pick up // objects. AvianPickupActor { + // Increase the maximum distance a bit to show off the + // prop changing its distance on scroll. interaction_distance: 15.0, ..default() }, @@ -195,21 +201,24 @@ fn accumulate_input( /// so we accumulate all input that happened since the last fixed update. #[derive(Debug, Component, Default)] struct InputAccumulation { + /// Accumulated mouse scrolling zoom: i32, + /// Accumulated mouse motion rotation: Vec2, + /// Was shift pressed during the last frame? shift: bool, } fn move_prop( time: Res