@@ -3,16 +3,12 @@ use bevy::prelude::*;
33use  bevy_landmass:: { AgentState ,  AgentTarget3d ,  Velocity3d } ; 
44
55use  crate :: { 
6-     GRAVITY , 
76    enemy:: { 
87        Enemy ,  ai:: EnemyState ,  shooting:: components:: EnemyBullet , 
98        spawn:: AgentEnemyEntityPointer , 
109    } , 
1110    game_flow:: states:: InGameState , 
12-     player:: { 
13-         Player , 
14-         spawn:: { PLAYER_CAPSULE_LENGTH ,  PLAYER_CAPSULE_RADIUS } , 
15-     } , 
11+     player:: Player , 
1612} ; 
1713
1814/// This system iterates over each enemy, and with a raycast, determines whether the enemy can see 
@@ -127,11 +123,13 @@ pub fn set_zero_velocity_if_not_chasing(
127123    enemy_query :  Query < ( & Enemy ,  & mut  LinearVelocity ) > , 
128124)  { 
129125    for  ( enemy,  mut  velocity)  in  enemy_query { 
130-         if  enemy. state  != EnemyState :: ChasingPlayer  && velocity. 0  != Vec3 :: ZERO 
126+         if  enemy. state  != EnemyState :: ChasingPlayer 
127+             && velocity. x  != 0.0 
128+             && velocity. z  != 0.0 
131129        { 
132-             info ! ( "current velocity: {}" ,  velocity. 0 ) ; 
133130            info ! ( "Enemy no longer chasing player, zeoring velocity!" ) ; 
134-             velocity. 0  = Vec3 :: ZERO ; 
131+             velocity. z  = 0.0 ; 
132+             velocity. x  = 0.0 
135133        } 
136134    } 
137135} 
@@ -167,49 +165,3 @@ pub fn handle_chasing_enemies(
167165        velocity. 0  = agent_velocity. velocity ; 
168166    } 
169167} 
170- 
171- pub  fn  update_enemy_on_ground ( 
172-     enemies :  Query < ( & mut  Enemy ,  & Transform ,  Entity ,  & mut  LinearVelocity ) > , 
173-     spatial_query :  SpatialQuery , 
174- )  { 
175-     for  ( mut  enemy,  transform,  player_entity,  mut  player_velocity)  in  enemies { 
176-         let  on_ground = spatial_query
177-             . cast_shape ( 
178-                 & Collider :: capsule ( 
179-                     PLAYER_CAPSULE_RADIUS , 
180-                     PLAYER_CAPSULE_LENGTH , 
181-                 ) , 
182-                 transform. translation , 
183-                 transform. rotation , 
184-                 Dir3 :: NEG_Y , 
185-                 & ShapeCastConfig  { 
186-                     max_distance :  0.1 , 
187-                     ..default ( ) 
188-                 } , 
189-                 & SpatialQueryFilter :: default ( ) 
190-                     . with_excluded_entities ( [ player_entity] ) , 
191-             ) 
192-             . is_some ( ) ; 
193-         if  enemy. on_ground  != on_ground { 
194-             enemy. on_ground  = on_ground; 
195-         } 
196- 
197-         if  on_ground { 
198-             if  player_velocity. y  <= 0.0  { 
199-                 player_velocity. y  = 0.0 ; 
200-             } 
201-         } 
202-     } 
203- } 
204- 
205- pub  fn  apply_gravity_over_time ( 
206-     mut  enemy_query :  Single < ( & Enemy ,  & mut  LinearVelocity ) > , 
207-     time :  Res < Time > , 
208- )  { 
209-     let  enemy = enemy_query. 0 ; 
210-     let  enemy_velocity = & mut  enemy_query. 1 ; 
211- 
212-     if  !enemy. on_ground  && enemy_velocity. y  > 0.0  { 
213-         enemy_velocity. y  -= GRAVITY  *  time. delta_secs ( ) ; 
214-     } 
215- } 
0 commit comments