fix physics
This commit is contained in:
parent
dc7b86157d
commit
6956df3d3b
4 changed files with 22 additions and 10 deletions
|
@ -10,7 +10,7 @@ mod scene;
|
|||
mod set;
|
||||
|
||||
pub const WORLD_DEPTH: f32 = 0.5;
|
||||
pub const PLAYER_DEPTH: f32 = 0.5;
|
||||
pub const PLAYER_DEPTH: f32 = 0.4;
|
||||
pub const PLAYER_SIZE_FRACTION: f32 = 0.8;
|
||||
|
||||
pub fn game_plugin(app: &mut App) {
|
||||
|
|
|
@ -34,7 +34,7 @@ impl FromWorld for PlayerSpawnOneshot {
|
|||
}
|
||||
|
||||
pub(super) fn player_plugin(app: &mut App) {
|
||||
app.add_systems(Update, (move_player, debug_player_pos))
|
||||
app.add_systems(Update, (move_player,))
|
||||
.init_resource::<PlayerSpawnOneshot>();
|
||||
}
|
||||
|
||||
|
@ -77,11 +77,9 @@ fn move_player(
|
|||
}
|
||||
|
||||
let orig = cam_transform.translation;
|
||||
println!("{orig:?}");
|
||||
cam_transform.translation -= ((orig - p_transform.translation.xy().extend(0.0)) / 30.0);
|
||||
|
||||
if moved {
|
||||
dbg!(mv);
|
||||
controller.translation = Some(Vec2::new(mv as f32 * 6., 0.));
|
||||
}
|
||||
}
|
||||
|
@ -151,8 +149,8 @@ fn add_player(
|
|||
//custom_shape: todo!(),
|
||||
//custom_mass: todo!(),
|
||||
//up: todo!(),
|
||||
//offset: todo!(),
|
||||
//slide: todo!(),
|
||||
offset: CharacterLength::Absolute(0.01),
|
||||
slide: true,
|
||||
//autostep: Some(CharacterAutostep {
|
||||
// max_height: CharacterLength::Relative(0.1),
|
||||
// min_width: CharacterLength::Absolute(1.0),
|
||||
|
@ -161,10 +159,10 @@ fn add_player(
|
|||
//max_slope_climb_angle: todo!(),
|
||||
//min_slope_slide_angle: todo!(),
|
||||
//apply_impulse_to_dynamic_bodies: todo!(),
|
||||
//snap_to_ground: Some(CharacterLength::Absolute(1.0)),
|
||||
// snap_to_ground: Some(CharacterLength::Absolute(100.0)),
|
||||
//filter_flags: todo!(),
|
||||
//filter_groups: todo!(),
|
||||
//normal_nudge_factor: todo!(),
|
||||
// normal_nudge_factor: 1.,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ impl PlayerCoords {
|
|||
pub fn get_collider(&self) -> Collider {
|
||||
let size = 0.5;
|
||||
|
||||
Collider::round_cuboid(size, size, 1.0)
|
||||
Collider::round_cuboid(size, size, 1.5)
|
||||
// Collider::cuboid(size, size)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -5,7 +5,7 @@ use game::game_plugin;
|
|||
|
||||
mod game;
|
||||
|
||||
const METER: f32 = 60.;
|
||||
const METER: f32 = 30.;
|
||||
|
||||
#[derive(States, Debug, Clone, PartialEq, Eq, Hash, Default)]
|
||||
enum AppState {
|
||||
|
@ -23,6 +23,18 @@ enum PausedState {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let rapier_config = RapierConfiguration {
|
||||
scaled_shape_subdivision: 10,
|
||||
timestep_mode: TimestepMode::Variable {
|
||||
max_dt: 0.1,
|
||||
time_scale: 1.0,
|
||||
substeps: 20,
|
||||
},
|
||||
gravity: Vec2::new(0.0, -9.81 * METER),
|
||||
physics_pipeline_active: true,
|
||||
query_pipeline_active: true,
|
||||
force_update_from_transform_changes: false,
|
||||
};
|
||||
App::new()
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_plugins(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(METER))
|
||||
|
@ -32,6 +44,7 @@ fn main() {
|
|||
.init_state::<AppState>()
|
||||
.init_state::<PausedState>()
|
||||
.insert_state(AppState::InGame) // TODO dont
|
||||
.insert_resource(rapier_config)
|
||||
.run();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue