Add Sensor component to colliders

This commit is contained in:
2025-08-06 14:44:38 -05:00
parent f553574e3e
commit d4ceaa6312
2 changed files with 8 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
use bevy_rapier2d::prelude::Collider; use bevy_rapier2d::prelude::*;
use rand::{Rng, SeedableRng}; use rand::{Rng, SeedableRng};
use std::time::Duration; use std::time::Duration;
@@ -118,6 +118,7 @@ pub fn spawn_asteroid(
commands.spawn(( commands.spawn((
Asteroid(AsteroidSize::Small), Asteroid(AsteroidSize::Small),
Collider::ball(collider_radius), Collider::ball(collider_radius),
Sensor,
Position(spawn.pos), Position(spawn.pos),
Velocity(spawn.vel), Velocity(spawn.vel),
Rotation(0.0), Rotation(0.0),

View File

@@ -10,7 +10,11 @@ use bevy::prelude::*;
use bevy_inspector_egui::InspectorOptions; use bevy_inspector_egui::InspectorOptions;
use bevy_inspector_egui::prelude::ReflectInspectorOptions; use bevy_inspector_egui::prelude::ReflectInspectorOptions;
use bevy_rapier2d::{plugin::{NoUserData, RapierPhysicsPlugin}, prelude::Collider, render::RapierDebugRenderPlugin}; use bevy_rapier2d::{
plugin::{NoUserData, RapierPhysicsPlugin},
prelude::*,
render::RapierDebugRenderPlugin,
};
use config::{ASTEROID_SMALL_COLOR, SHIP_THRUSTER_COLOR_ACTIVE, SHIP_THRUSTER_COLOR_INACTIVE}; use config::{ASTEROID_SMALL_COLOR, SHIP_THRUSTER_COLOR_ACTIVE, SHIP_THRUSTER_COLOR_INACTIVE};
pub struct AsteroidPlugin; pub struct AsteroidPlugin;
@@ -180,6 +184,7 @@ fn spawn_player(mut commands: Commands, game_assets: Res<GameAssets>) {
commands commands
.spawn(( .spawn((
Collider::ball(0.7), Collider::ball(0.7),
Sensor,
Ship, Ship,
Wrapping, Wrapping,
Position(Vec2::default()), Position(Vec2::default()),