From 16a578d2945e8579290fdb07d763788b45ec1b42 Mon Sep 17 00:00:00 2001 From: yuni Date: Mon, 16 Sep 2024 02:20:24 +0200 Subject: [PATCH] particles: make them bearable in first-person-view --- src/camera.rs | 6 +++++- src/visual.rs | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/camera.rs b/src/camera.rs index 1ac51cc..a38e27a 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -570,10 +570,14 @@ pub fn apply_input_to_player( // Visual effect if bike.is_none() && acceleration_total.length_squared() > 1e-4 { let thruster_direction = acceleration_total.normalize(); + let thruster_pos = pos.0 - 0.3 * thruster_direction; let thruster_v = v.0 - 5.0 * thruster_direction; ew_effect.send(visual::SpawnEffectEvent { duration: 2.0, - class: visual::Effects::ThrusterParticle(pos.clone(), LinearVelocity::from(thruster_v)), + class: visual::Effects::ThrusterParticle( + Position::from(thruster_pos), + LinearVelocity::from(thruster_v), + ), }); } } else { diff --git a/src/visual.rs b/src/visual.rs index a9fc383..bea5976 100644 --- a/src/visual.rs +++ b/src/visual.rs @@ -196,6 +196,9 @@ pub fn spawn_effects( mesh: meshes.add(Mesh::from(Rectangle::new(0.2, 0.2))), material: materials.add(StandardMaterial { base_color_texture: Some(texture), + // Make sure to make the particle invisible on spawn, + // since rotation from WantsToLookAt hasn't been applied yet + base_color: Color::srgba(1.0, 1.0, 1.0, 0.0), perceptual_roughness: 1.0, metallic: 0.5, unlit: true,