mirror of
https://codeberg.org/schrottkatze/mgd2-tram-championships.git
synced 2025-07-01 17:27:38 +00:00
32 lines
899 B
Rust
32 lines
899 B
Rust
use bevy::prelude::*;
|
|
use bevy_rapier3d::prelude::{Collider, RigidBody};
|
|
use bevy_third_person_camera::ThirdPersonCameraTarget;
|
|
use log::info;
|
|
|
|
use crate::{AppState, cleanup};
|
|
|
|
pub fn plugin(app: &mut App) {
|
|
app.register_type::<StaticColliderConfig>()
|
|
// .add_systems(OnEnter(AppState::Ingame), test_spawn_on_init)
|
|
.add_systems(Update, add_colliders_to_things_that_need_them);
|
|
}
|
|
|
|
// uses blender coords
|
|
#[derive(Component, Clone, Copy, Reflect)]
|
|
#[reflect(Component)]
|
|
pub struct StaticColliderConfig {
|
|
x: f32,
|
|
y: f32,
|
|
z: f32,
|
|
}
|
|
|
|
fn add_colliders_to_things_that_need_them(
|
|
mut c: Commands,
|
|
to_modify: Query<(Entity, &StaticColliderConfig), Without<Collider>>,
|
|
) {
|
|
for (entity, StaticColliderConfig { x, y, z }) in to_modify.iter() {
|
|
info!("meow");
|
|
c.entity(entity)
|
|
.insert(Collider::cuboid(*x / 2., *z / 2., -*y / 2.));
|
|
}
|
|
}
|