custom camera rig
* should not go into level geometry anymore
This commit is contained in:
27
src/main.rs
27
src/main.rs
@@ -10,6 +10,7 @@ mod heads_ui;
|
||||
mod keys;
|
||||
mod movables;
|
||||
mod npc;
|
||||
mod physics_layers;
|
||||
mod platforms;
|
||||
mod player;
|
||||
mod shooting;
|
||||
@@ -25,11 +26,10 @@ use bevy::core_pipeline::tonemapping::Tonemapping;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::view::ColorGrading;
|
||||
use bevy::scene::SceneInstanceReady;
|
||||
use bevy_dolly::prelude::*;
|
||||
use bevy_tnua::prelude::TnuaControllerPlugin;
|
||||
use bevy_tnua_avian3d::TnuaAvian3dPlugin;
|
||||
use bevy_trenchbroom::prelude::*;
|
||||
use camera::GameCameraRig;
|
||||
use physics_layers::GameLayer;
|
||||
|
||||
#[derive(Resource, Reflect, Debug)]
|
||||
#[reflect(Resource)]
|
||||
@@ -41,9 +41,6 @@ struct DebugVisuals {
|
||||
pub cam_follow: bool,
|
||||
}
|
||||
|
||||
#[derive(Component, Debug)]
|
||||
pub struct MainCamera;
|
||||
|
||||
fn main() {
|
||||
let mut app = App::new();
|
||||
|
||||
@@ -73,8 +70,6 @@ fn main() {
|
||||
// app.add_plugins(PhysicsDebugPlugin::default());
|
||||
// app.add_plugins(bevy_inspector_egui::quick::WorldInspectorPlugin::default());
|
||||
|
||||
app.add_systems(Update, Dolly::<MainCamera>::update_active);
|
||||
|
||||
app.add_plugins(alien::plugin);
|
||||
app.add_plugins(cash::plugin);
|
||||
app.add_plugins(player::plugin);
|
||||
@@ -91,6 +86,7 @@ fn main() {
|
||||
app.add_plugins(cutscene::plugin);
|
||||
app.add_plugins(controls::plugin);
|
||||
app.add_plugins(sounds::plugin);
|
||||
app.add_plugins(camera::plugin);
|
||||
|
||||
app.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
@@ -99,7 +95,7 @@ fn main() {
|
||||
|
||||
app.add_plugins(TrenchBroomPlugin(TrenchBroomConfig::new("hedz")));
|
||||
|
||||
app.add_systems(Startup, (setup_cam, write_trenchbroom_config, music));
|
||||
app.add_systems(Startup, (write_trenchbroom_config, music));
|
||||
app.add_systems(PostStartup, setup_scene);
|
||||
app.add_systems(
|
||||
Update,
|
||||
@@ -109,19 +105,12 @@ fn main() {
|
||||
app.run();
|
||||
}
|
||||
|
||||
fn setup_cam(mut commands: Commands) {
|
||||
commands.spawn((
|
||||
Camera3d::default(),
|
||||
MainCamera,
|
||||
Rig::builder()
|
||||
.with(GameCameraRig::new_with_arm(Vec3::new(0., 5., 14.)))
|
||||
.build(),
|
||||
));
|
||||
}
|
||||
|
||||
fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
commands
|
||||
.spawn(SceneRoot(asset_server.load("maps/map1.map#Scene")))
|
||||
.spawn((
|
||||
CollisionLayers::new(LayerMask(GameLayer::Level.to_bits()), LayerMask::ALL),
|
||||
SceneRoot(asset_server.load("maps/map1.map#Scene")),
|
||||
))
|
||||
.observe(|_t: Trigger<SceneInstanceReady>| {
|
||||
//TODO: use for state driven map loading
|
||||
info!("map loaded");
|
||||
|
||||
Reference in New Issue
Block a user