mirror of
https://codeberg.org/schrottkatze/mgd2-tram-championships.git
synced 2025-07-02 09:37:40 +00:00
COLLIDERSSSS!!!!!!!
This commit is contained in:
parent
7e531d42a8
commit
643a16f008
14 changed files with 541 additions and 33 deletions
|
@ -1,21 +1,32 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_rapier3d::prelude::{Collider, RigidBody};
|
||||
use bevy_third_person_camera::ThirdPersonCameraTarget;
|
||||
use log::info;
|
||||
|
||||
use crate::cleanup;
|
||||
use crate::{AppState, cleanup};
|
||||
|
||||
pub fn setup(
|
||||
mut c: Commands,
|
||||
asset_server: Res<AssetServer>,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
let scene_handle = asset_server.load(GltfAssetLabel::Scene(0).from_asset("gltf/test.glb"));
|
||||
c.spawn((
|
||||
Mesh3d(meshes.add(Cuboid::new(1., 1., 1.))),
|
||||
MeshMaterial3d(materials.add(Color::BLACK)),
|
||||
ThirdPersonCameraTarget,
|
||||
cleanup::Scene,
|
||||
));
|
||||
c.spawn(SceneRoot(scene_handle));
|
||||
info!("Scene spawned!")
|
||||
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.));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue