particles: make them bearable in first-person-view

This commit is contained in:
yuni 2024-09-16 02:20:24 +02:00
parent 9d42c64d03
commit 16a578d294
2 changed files with 8 additions and 1 deletions

View file

@ -570,10 +570,14 @@ pub fn apply_input_to_player(
// Visual effect // Visual effect
if bike.is_none() && acceleration_total.length_squared() > 1e-4 { if bike.is_none() && acceleration_total.length_squared() > 1e-4 {
let thruster_direction = acceleration_total.normalize(); let thruster_direction = acceleration_total.normalize();
let thruster_pos = pos.0 - 0.3 * thruster_direction;
let thruster_v = v.0 - 5.0 * thruster_direction; let thruster_v = v.0 - 5.0 * thruster_direction;
ew_effect.send(visual::SpawnEffectEvent { ew_effect.send(visual::SpawnEffectEvent {
duration: 2.0, 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 { } else {

View file

@ -196,6 +196,9 @@ pub fn spawn_effects(
mesh: meshes.add(Mesh::from(Rectangle::new(0.2, 0.2))), mesh: meshes.add(Mesh::from(Rectangle::new(0.2, 0.2))),
material: materials.add(StandardMaterial { material: materials.add(StandardMaterial {
base_color_texture: Some(texture), 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, perceptual_roughness: 1.0,
metallic: 0.5, metallic: 0.5,
unlit: true, unlit: true,