11use  avian_rerecast:: AvianBackendPlugin ; 
2- use  avian3d:: prelude:: * ; 
32use  bevy:: prelude:: * ; 
4- use  bevy_landmass:: { Agent3d ,   debug:: Landmass3dDebugPlugin ,  prelude:: * } ; 
3+ use  bevy_landmass:: { debug:: Landmass3dDebugPlugin ,  prelude:: * } ; 
54use  bevy_rerecast:: { debug:: DetailNavmeshGizmo ,  prelude:: * } ; 
65use  landmass_rerecast:: { 
76    Island3dBundle ,  LandmassRerecastPlugin ,  NavMeshHandle3d , 
87} ; 
98
109use  crate :: { 
11-     character_controller:: MAX_SLOPE_ANGLE , 
12-     character_controller:: MAX_SLOPE_ANGLE , 
13-     enemy:: { Enemy ,  spawn:: AgentEnemyEntityPointer } , 
14-     game_flow:: states:: GameLoadingState , 
15-     game_flow:: states:: GameLoadingState , 
10+     character_controller:: MAX_SLOPE_ANGLE ,  game_flow:: states:: GameLoadingState , 
1611} ; 
1712
18- pub  const  ENEMY_AGENT_RADIUS :  f32  = 0.3  ; 
13+ pub  const  ENEMY_AGENT_RADIUS :  f32  = 0.4  ; 
1914
2015pub  struct  NavMeshPathfindingPlugin ; 
2116
@@ -30,7 +25,7 @@ impl Plugin for NavMeshPathfindingPlugin {
3025            OnEnter ( GameLoadingState :: CollidersReady ) , 
3126            generate_navmesh_when_map_colliders_ready, 
3227        ) ; 
33-         app. add_systems ( Update ,  ( update_agent_velocity,  snap_agent_to_floor ) ) ; 
28+         app. add_systems ( Update ,  update_agent_velocity) ; 
3429    } 
3530} 
3631
@@ -62,7 +57,7 @@ fn generate_navmesh_when_map_colliders_ready(
6257        commands. insert_resource ( ArchipelagoRef ( archipelago_id) ) ; 
6358
6459        let  navmesh = generator. generate ( NavmeshSettings  { 
65-             agent_radius :  ENEMY_AGENT_RADIUS , 
60+             agent_radius :  0.3 , 
6661            // this is pretty important, so the agent doesnt try to climb some very high ledge 
6762            walkable_climb :  0.25 , 
6863            walkable_slope_angle :  MAX_SLOPE_ANGLE , 
@@ -96,51 +91,3 @@ fn update_agent_velocity(
9691        agent_velocity. velocity  = desired_velocity. velocity ( ) ; 
9792    } 
9893} 
99- 
100- // FIXME: dont need this anymore 
101- fn  snap_agent_to_floor ( 
102-     query :  Query < 
103-         ( Entity ,  & Transform ,  & mut  LinearVelocity ,  & ShapeHits ) , 
104-         With < Enemy > , 
105-     > , 
106-     time :  Res < Time > , 
107-     spatial_query :  SpatialQuery , 
108- )  { 
109-     for  ( enemy_entity,  enemy_transform,  mut  enemy_velocity,  shape_hits)  in  query
110-     { 
111-         let  Some ( first_hit)  = shape_hits. 0 . get ( 0 )  else  { 
112-             info ! ( "snap_agent_to_floor: No hits down found" ) ; 
113-             continue ; 
114-         } ; 
115-         info ! ( "first_hit: {:?}" ,  first_hit) ; 
116- 
117-         // let hit_down_point = 
118-         //     ray_down_origin + ray_down_direction * hit_down.distance; 
119-         // let hit_down_y = hit_down_point.y; 
120-         // let enemy_y = enemy_transform.translation.y; 
121-         // let difference_y = hit_down_y - enemy_y; 
122-         // if difference_y.abs() < 0.3 { 
123-         //     info!("Snapping enemy to slope"); 
124-         //     enemy_velocity.y = difference_y / time.delta_secs(); 
125-         // } else { 
126-         //     info!( 
127-         //         "Not snapping enemy, difference between hit down and player \ 
128-         //          too large" 
129-         //     ); 
130-         // } 
131-         // let ray_down_origin = enemy_transform.translation + Vec3::Y * 0.5; 
132-         // let ray_down_direction = Dir3::NEG_Y; 
133-         // let max_down_distance = 1.0; 
134-         // 
135-         // if let Some(hit_down) = spatial_query.cast_ray( 
136-         //     ray_down_origin, 
137-         //     ray_down_direction, 
138-         //     max_down_distance, 
139-         //     true, 
140-         //     &SpatialQueryFilter::default() 
141-         //         .with_excluded_entities([enemy_entity]), 
142-         // ) { 
143-         // } else { 
144-         // } 
145-     } 
146- } 
0 commit comments