diff --git a/src/navigation.rs b/src/navigation.rs index 39f9aae..cc4762f 100644 --- a/src/navigation.rs +++ b/src/navigation.rs @@ -145,6 +145,14 @@ fn movement_controls( } if direction.length_squared() != 0. { direction = direction.normalize(); + if direction.x > 0. { + direction.x *= config.forward_movement_factor; + } else if direction.x < 0. { + direction.x *= config.backward_movement_factor; + } + if direction.y != 0. { + direction.y *= config.strafe_movement_factor; + } let strength = if let (Some(forward), Some(backward), Some(left), Some(right)) = ( config.action_forward.clone(), config.action_backward.clone(), @@ -168,7 +176,7 @@ fn movement_controls( let s = if sprinting { **max_speed } else { - **max_speed / 3. + **max_speed / config.sprint_movement_factor }; speed.0 = s; direction *= s; @@ -438,6 +446,10 @@ pub struct NavigationConfig { pub action_rotate_left: Option, pub action_rotate_right: Option, pub action_sprint: Option, + pub forward_movement_factor: f32, + pub backward_movement_factor: f32, + pub strafe_movement_factor: f32, + pub sprint_movement_factor: f32, pub movement_states: Vec, pub movement_control_states: Vec, } @@ -452,6 +464,10 @@ impl Default for NavigationConfig { action_rotate_left: None, action_rotate_right: None, action_sprint: None, + forward_movement_factor: 1., + backward_movement_factor: 1., + strafe_movement_factor: 1., + sprint_movement_factor: 3., movement_states: vec![], movement_control_states: vec![], }