You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
827 B
Rust

use super::*;
pub use avian2d::prelude::*;
/// 2D Physics systems, resources, events, etc.
pub struct Physics2dPlugin;
impl Plugin for Physics2dPlugin {
fn build(&self, app: &mut App) {
app.add_plugins((PhysicsPlugins::default(), PhysicsDebugPlugin::default()))
.add_systems(
Update,
toggle_physics_debug_render.run_if(state_changed::<DebuggingState>),
);
}
}
fn toggle_physics_debug_render(
state: Res<State<DebuggingState>>,
mut config_store: ResMut<GizmoConfigStore>,
) {
let (_, config) = config_store.config_mut::<PhysicsGizmos>();
*config = match state.get() {
// TODO: Not all, don't want to hide mesh
DebuggingState::On => PhysicsGizmos::default(),
DebuggingState::Off => PhysicsGizmos::none(),
};
}