Player drag and alignment with gravity

+player jumping
This commit is contained in:
2025-06-25 15:55:25 -04:00
parent 8c3281f9cc
commit 11d6c52791
6 changed files with 118 additions and 24 deletions

View File

@@ -2,20 +2,48 @@ use bevy::prelude::*;
use bevy_rapier3d::prelude::GravityScale;
#[derive(Component, Default, Reflect)]
#[require(PlayerVelocity)]
#[require(PlayerVelocity, MoveSpeed, JumpSpeed, PlayerDrag)]
pub struct PlayerMotion(pub Vec3);
#[derive(Component, Default, Reflect)]
pub struct PlayerForce(pub Vec3);
#[derive(Component, Default, Reflect)]
#[derive(Component, Reflect)]
#[require(GravityScale)]
pub struct GravityDirection(pub Option<Dir3>);
impl Default for GravityDirection {
fn default() -> Self {
Self::DOWN
}
}
impl GravityDirection {
pub const DOWN: GravityDirection = GravityDirection(Some(Dir3::NEG_Y));
#[allow(dead_code)]
pub const NONE: GravityDirection = GravityDirection(None);
}
#[derive(Component, Default, Reflect)]
pub struct PlayerVelocity(pub Vec3);
#[derive(Component, Reflect)]
pub struct MoveSpeed(pub f32);
impl Default for MoveSpeed {
fn default() -> Self {
Self(10.0)
}
}
#[derive(Component, Reflect)]
pub struct JumpSpeed(pub f32);
impl Default for JumpSpeed {
fn default() -> Self {
Self(10.0)
}
}
#[derive(Component, Default, Reflect)]
pub struct PlayerDrag(pub f32);