@@ -83,6 +83,8 @@ pub struct FpsController {
83
83
pub move_mode : MoveMode ,
84
84
pub radius : f32 ,
85
85
pub gravity : f32 ,
86
+ // If the distance to the ground is less than this value, the player is considered grounded
87
+ pub grounded_distance : f32 ,
86
88
pub walk_speed : f32 ,
87
89
pub run_speed : f32 ,
88
90
pub forward_speed : f32 ,
@@ -129,6 +131,7 @@ impl Default for FpsController {
129
131
fn default ( ) -> Self {
130
132
Self {
131
133
move_mode : MoveMode :: Ground ,
134
+ grounded_distance : 0.125 ,
132
135
radius : 0.5 ,
133
136
fly_speed : 10.0 ,
134
137
fast_fly_speed : 30.0 ,
@@ -183,9 +186,6 @@ impl Default for FpsController {
183
186
// Used as padding by camera pitching (up/down) to avoid spooky math problems
184
187
const ANGLE_EPSILON : f32 = 0.001953125 ;
185
188
186
- // If the distance to the ground is less than this value, the player is considered grounded
187
- const GROUNDED_DISTANCE : f32 = 0.125 ;
188
-
189
189
const SLIGHT_SCALE_DOWN : f32 = 0.9375 ;
190
190
191
191
pub fn fps_controller_input (
@@ -286,7 +286,7 @@ pub fn fps_controller_move(
286
286
// We do not want the shape cast to detect it,
287
287
// so provide a slightly smaller collider in the XZ plane
288
288
& scaled_collider_laterally ( & collider, SLIGHT_SCALE_DOWN ) ,
289
- ShapeCastOptions :: with_max_time_of_impact ( GROUNDED_DISTANCE ) ,
289
+ ShapeCastOptions :: with_max_time_of_impact ( controller . grounded_distance ) ,
290
290
filter,
291
291
) ;
292
292
0 commit comments