fix line of sight origin
This commit is contained in:
@@ -68,7 +68,7 @@ fn on_trigger_gun(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut t = Transform::from_translation(state.pos).with_rotation(rotation);
|
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
|
commands
|
||||||
.spawn((
|
.spawn((
|
||||||
|
|||||||
@@ -95,26 +95,21 @@ fn on_trigger_thrown(
|
|||||||
|
|
||||||
const SPEED: f32 = 35.;
|
const SPEED: f32 = 35.;
|
||||||
|
|
||||||
|
let pos = state.pos + state.dir.as_vec3() * -0.8;
|
||||||
|
|
||||||
let vel = if let Some(target) = state.target {
|
let vel = if let Some(target) = state.target {
|
||||||
let t = query_transform
|
let t = query_transform
|
||||||
.get(target)
|
.get(target)
|
||||||
.expect("target must have transform");
|
.expect("target must have transform");
|
||||||
|
|
||||||
launch_velocity(
|
launch_velocity(pos, t.translation, SPEED, 9.81)
|
||||||
state.pos + state.dir.as_vec3() * 2.,
|
.map(|(low, _)| low)
|
||||||
t.translation,
|
.unwrap()
|
||||||
SPEED,
|
|
||||||
9.81,
|
|
||||||
)
|
|
||||||
.map(|(low, _)| low)
|
|
||||||
.unwrap()
|
|
||||||
} else {
|
} else {
|
||||||
state.rot.mul_quat(Quat::from_rotation_y(-PI / 2.))
|
state.rot.mul_quat(Quat::from_rotation_y(-PI / 2.))
|
||||||
* (Vec3::new(2., 1., 0.).normalize() * SPEED)
|
* (Vec3::new(2., 1., 0.).normalize() * SPEED)
|
||||||
};
|
};
|
||||||
|
|
||||||
let t = Transform::from_translation(state.pos);
|
|
||||||
|
|
||||||
let (mesh, explosion_animation) = match state.head {
|
let (mesh, explosion_animation) = match state.head {
|
||||||
8 => (assets.hammer.clone(), false),
|
8 => (assets.hammer.clone(), false),
|
||||||
_ => (assets.molotov.clone(), true),
|
_ => (assets.molotov.clone(), true),
|
||||||
@@ -122,6 +117,7 @@ fn on_trigger_thrown(
|
|||||||
|
|
||||||
commands
|
commands
|
||||||
.spawn((
|
.spawn((
|
||||||
|
Transform::from_translation(pos),
|
||||||
Name::new("projectile-thrown"),
|
Name::new("projectile-thrown"),
|
||||||
ThrownProjectile {
|
ThrownProjectile {
|
||||||
impact_animation: explosion_animation,
|
impact_animation: explosion_animation,
|
||||||
@@ -135,7 +131,6 @@ fn on_trigger_thrown(
|
|||||||
Mass(0.01),
|
Mass(0.01),
|
||||||
LinearVelocity(vel),
|
LinearVelocity(vel),
|
||||||
Visibility::default(),
|
Visibility::default(),
|
||||||
t,
|
|
||||||
))
|
))
|
||||||
.with_child((
|
.with_child((
|
||||||
AutoRotation(Quat::from_rotation_x(0.4) * Quat::from_rotation_z(0.3)),
|
AutoRotation(Quat::from_rotation_x(0.4) * Quat::from_rotation_z(0.3)),
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ fn line_of_sight(
|
|||||||
) -> bool {
|
) -> bool {
|
||||||
if let Some(_hit) = spatial_query.cast_shape(
|
if let Some(_hit) = spatial_query.cast_shape(
|
||||||
&Collider::sphere(0.1),
|
&Collider::sphere(0.1),
|
||||||
player_pos + -delta.normalize(),
|
player_pos + -delta.normalize() + (Vec3::Y * 2.),
|
||||||
Quat::default(),
|
Quat::default(),
|
||||||
Dir3::new(-delta).unwrap(),
|
Dir3::new(-delta).unwrap(),
|
||||||
&ShapeCastConfig {
|
&ShapeCastConfig {
|
||||||
|
|||||||
Reference in New Issue
Block a user