50 lines
1.0 KiB
Rust
50 lines
1.0 KiB
Rust
use bevy::prelude::*;
|
|
use bevy_rapier3d::prelude::GravityScale;
|
|
|
|
#[derive(Component, Default, Reflect)]
|
|
#[require(PlayerVelocity, MoveSpeed, JumpSpeed, PlayerDrag)]
|
|
pub struct PlayerMotion(pub Vec3);
|
|
|
|
#[derive(Component, Default, Reflect)]
|
|
pub struct PlayerForce(pub Vec3);
|
|
|
|
#[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);
|