mgd2-tram-championships/src/game/scene.rs

33 lines
899 B
Rust
Raw Normal View History

use bevy::prelude::*;
2025-06-26 22:19:05 +02:00
use bevy_rapier3d::prelude::{Collider, RigidBody};
use bevy_third_person_camera::ThirdPersonCameraTarget;
2025-06-26 22:19:05 +02:00
use log::info;
2025-06-26 22:19:05 +02:00
use crate::{AppState, cleanup};
2025-06-26 22:19:05 +02:00
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,
2025-06-26 22:19:05 +02:00
to_modify: Query<(Entity, &StaticColliderConfig), Without<Collider>>,
) {
2025-06-26 22:19:05 +02:00
for (entity, StaticColliderConfig { x, y, z }) in to_modify.iter() {
info!("meow");
c.entity(entity)
.insert(Collider::cuboid(*x / 2., *z / 2., -*y / 2.));
}
}