diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 2c39007d10..4b9c7d0bb9 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -11,6 +11,7 @@ pub enum Effect { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Projectile { pub hit_ground: Vec, + pub hit_wall: Vec, pub hit_entity: Vec, } diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index b863558132..4300513aa5 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -145,6 +145,7 @@ impl<'a> System<'a> for Sys { dir: controller.look_dir, projectile: Projectile { hit_ground: vec![projectile::Effect::Stick], + hit_wall: vec![projectile::Effect::Stick], hit_entity: vec![ projectile::Effect::Damage(10), projectile::Effect::Vanish, diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index d1109e21ac..d6f7b6ac64 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -38,10 +38,6 @@ impl<'a> System<'a> for Sys { ) .join() { - if let Some(vel) = velocities.get(entity) { - ori.0 = vel.0.normalized(); - } - // Hit ground if physics.on_ground { for effect in projectile.hit_ground.drain(..) { @@ -53,6 +49,17 @@ impl<'a> System<'a> for Sys { } } } + // Hit wall + if physics.on_wall.is_some() { + for effect in projectile.hit_wall.drain(..) { + match effect { + projectile::Effect::Stick => { + velocities.remove(entity); + } + _ => {} + } + } + } // Hit entity if let Some(other) = physics.touch_entity { for effect in projectile.hit_entity.drain(..) { @@ -72,6 +79,10 @@ impl<'a> System<'a> for Sys { } } } + + if let Some(vel) = velocities.get(entity) { + ori.0 = vel.0.normalized(); + } } } }