diff --git a/common/src/states/leap_melee.rs b/common/src/states/leap_melee.rs index b49f49c342..3561524f88 100644 --- a/common/src/states/leap_melee.rs +++ b/common/src/states/leap_melee.rs @@ -97,6 +97,7 @@ impl CharacterBehavior for Data { vertical: self.static_data.vertical_leap_strength, forward: self.static_data.forward_leap_strength, progress, + direction: MovementDirection::Look, }, 0.15, ); diff --git a/common/src/states/repeater_ranged.rs b/common/src/states/repeater_ranged.rs index 48a50d2627..7f90a22922 100644 --- a/common/src/states/repeater_ranged.rs +++ b/common/src/states/repeater_ranged.rs @@ -75,6 +75,7 @@ impl CharacterBehavior for Data { vertical: leap_strength, forward: 10.0, progress, + direction: MovementDirection::Move, }, 1.0, ); diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index a6b1844638..df8cff620f 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -202,19 +202,19 @@ pub fn handle_forced_movement( vertical, forward, progress, + direction, } => { + let dir = direction.get_2d_dir(data); // Apply jumping force update.vel.0 = Vec3::new( - data.inputs.look_dir.x, - data.inputs.look_dir.y, + dir.x, + dir.y, vertical, ) // Multiply decreasing amount linearly over time (with average of 1) * 2.0 * progress - // Apply inputted movement directions with some efficiency - + (data.inputs.look_dir.try_normalized().unwrap_or_default()) - .try_normalized() - .unwrap_or_default() + // Apply direction + + Vec3::from(dir) // Multiply by forward leap strength * forward // Control forward movement based on look direction. @@ -555,8 +555,27 @@ pub enum ForcedMovement { vertical: f32, forward: f32, progress: f32, + direction: MovementDirection, }, Hover { move_input: f32, }, } + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +pub enum MovementDirection { + Look, + Move, +} + +impl MovementDirection { + pub fn get_2d_dir(self, data: &JoinData) -> Vec2 { + use MovementDirection::*; + match self { + Look => data.inputs.look_dir.xy(), + Move => data.inputs.move_dir, + } + .try_normalized() + .unwrap_or_default() + } +}