fix line of sight origin

This commit is contained in:
2025-04-12 15:21:27 +02:00
parent 3bdcf47c57
commit c79c64dadd
3 changed files with 8 additions and 13 deletions

View File

@@ -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((

View File

@@ -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)),