diff --git a/src/abilities/gun.rs b/src/abilities/gun.rs index 89f642f..1f4b285 100644 --- a/src/abilities/gun.rs +++ b/src/abilities/gun.rs @@ -68,7 +68,7 @@ fn on_trigger_gun( }; let mut t = Transform::from_translation(state.pos).with_rotation(rotation); - t.translation += t.forward().as_vec3() * 2.; + t.translation += (t.forward().as_vec3() * 2.) + (Vec3::Y * 0.6); commands .spawn(( diff --git a/src/abilities/thrown.rs b/src/abilities/thrown.rs index b0a2261..049b607 100644 --- a/src/abilities/thrown.rs +++ b/src/abilities/thrown.rs @@ -95,26 +95,21 @@ fn on_trigger_thrown( const SPEED: f32 = 35.; + let pos = state.pos + state.dir.as_vec3() * -0.8; + let vel = if let Some(target) = state.target { let t = query_transform .get(target) .expect("target must have transform"); - launch_velocity( - state.pos + state.dir.as_vec3() * 2., - t.translation, - SPEED, - 9.81, - ) - .map(|(low, _)| low) - .unwrap() + launch_velocity(pos, t.translation, SPEED, 9.81) + .map(|(low, _)| low) + .unwrap() } else { state.rot.mul_quat(Quat::from_rotation_y(-PI / 2.)) * (Vec3::new(2., 1., 0.).normalize() * SPEED) }; - let t = Transform::from_translation(state.pos); - let (mesh, explosion_animation) = match state.head { 8 => (assets.hammer.clone(), false), _ => (assets.molotov.clone(), true), @@ -122,6 +117,7 @@ fn on_trigger_thrown( commands .spawn(( + Transform::from_translation(pos), Name::new("projectile-thrown"), ThrownProjectile { impact_animation: explosion_animation, @@ -135,7 +131,6 @@ fn on_trigger_thrown( Mass(0.01), LinearVelocity(vel), Visibility::default(), - t, )) .with_child(( AutoRotation(Quat::from_rotation_x(0.4) * Quat::from_rotation_z(0.3)), diff --git a/src/aim/mod.rs b/src/aim/mod.rs index ecba853..cc29579 100644 --- a/src/aim/mod.rs +++ b/src/aim/mod.rs @@ -182,7 +182,7 @@ fn line_of_sight( ) -> bool { if let Some(_hit) = spatial_query.cast_shape( &Collider::sphere(0.1), - player_pos + -delta.normalize(), + player_pos + -delta.normalize() + (Vec3::Y * 2.), Quat::default(), Dir3::new(-delta).unwrap(), &ShapeCastConfig {