Tnua and dolly (#2)
* character controller + camera rig * make tnua work * cash collect
This commit is contained in:
47
src/main.rs
47
src/main.rs
@@ -1,5 +1,7 @@
|
||||
mod alien;
|
||||
mod camera;
|
||||
mod cash;
|
||||
mod player;
|
||||
mod tb_entities;
|
||||
|
||||
use avian3d::PhysicsPlugins;
|
||||
@@ -7,8 +9,11 @@ use avian3d::prelude::*;
|
||||
use bevy::core_pipeline::tonemapping::Tonemapping;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::view::ColorGrading;
|
||||
use bevy_flycam::prelude::*;
|
||||
use bevy_dolly::prelude::*;
|
||||
use bevy_tnua::prelude::TnuaControllerPlugin;
|
||||
use bevy_tnua_avian3d::TnuaAvian3dPlugin;
|
||||
use bevy_trenchbroom::prelude::*;
|
||||
use camera::GameCameraRig;
|
||||
|
||||
#[derive(Resource, Reflect, Debug)]
|
||||
#[reflect(Resource)]
|
||||
@@ -19,6 +24,9 @@ struct DebugVisuals {
|
||||
pub shadows: bool,
|
||||
}
|
||||
|
||||
#[derive(Component, Debug)]
|
||||
pub struct MainCamera;
|
||||
|
||||
fn main() {
|
||||
let mut app = App::new();
|
||||
|
||||
@@ -35,18 +43,18 @@ fn main() {
|
||||
}));
|
||||
|
||||
app.add_plugins(PhysicsPlugins::default());
|
||||
// app.add_plugins(PhysicsDebugPlugin::default());
|
||||
app.add_plugins(PhysicsDebugPlugin::default());
|
||||
app.add_plugins((
|
||||
TnuaControllerPlugin::new(FixedUpdate),
|
||||
TnuaAvian3dPlugin::new(FixedUpdate),
|
||||
));
|
||||
|
||||
// bevy_flycam setup so we can get a closer look at the scene, mainly for debugging
|
||||
app.add_plugins(PlayerPlugin);
|
||||
app.add_systems(Update, Dolly::<MainCamera>::update_active);
|
||||
|
||||
app.add_plugins(alien::plugin);
|
||||
app.add_plugins(cash::plugin);
|
||||
app.add_plugins(player::plugin);
|
||||
|
||||
app.insert_resource(MovementSettings {
|
||||
sensitivity: 0.00005,
|
||||
speed: 12.,
|
||||
});
|
||||
app.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 400.,
|
||||
@@ -55,7 +63,7 @@ fn main() {
|
||||
|
||||
app.add_plugins(TrenchBroomPlugin(TrenchBroomConfig::new("hedz")));
|
||||
|
||||
app.add_systems(Startup, (write_trenchbroom_config, music));
|
||||
app.add_systems(Startup, (setup_cam, write_trenchbroom_config, music));
|
||||
app.add_systems(PostStartup, setup_scene);
|
||||
app.add_systems(
|
||||
Update,
|
||||
@@ -65,6 +73,16 @@ 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")));
|
||||
|
||||
@@ -80,14 +98,6 @@ fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
..default()
|
||||
},
|
||||
));
|
||||
|
||||
commands.spawn((
|
||||
SceneRoot(
|
||||
asset_server
|
||||
.load(GltfAssetLabel::Scene(0).from_asset("models/heads/angry_demonstrator.glb")),
|
||||
),
|
||||
Transform::from_xyz(0.0, 5.0, 0.0),
|
||||
));
|
||||
}
|
||||
|
||||
fn spawn_box(
|
||||
@@ -110,9 +120,6 @@ fn spawn_box(
|
||||
|
||||
fn music(asset_server: Res<AssetServer>, mut commands: Commands) {
|
||||
commands.spawn(AudioPlayer::new(asset_server.load("sfx/music/02.ogg")));
|
||||
commands.spawn(AudioPlayer::new(
|
||||
asset_server.load("sfx/heads/angry_demonstrator.ogg"),
|
||||
));
|
||||
}
|
||||
|
||||
fn write_trenchbroom_config(server: Res<TrenchBroomServer>) {
|
||||
|
||||
Reference in New Issue
Block a user