bevy_hanabi icon indicating copy to clipboard operation
bevy_hanabi copied to clipboard

Rotation of emitter doesn't affect spawned particles

Open barsoosayque opened this issue 5 months ago • 0 comments

Crate versions bevy version: 0.14.1 bevy_hanabi version: 0.12.2

Describe the bug Rotation part of ParticleEffect's GlobalTransform does not rotate velocity of spawned particles. Seems like https://github.com/djeedai/bevy_hanabi/pull/43 should've fixed that, but maybe there was a regression ? Or I'm misunderstanding something.

Expected behavior Particles rotate towards emitter's own rotation.

To Reproduce Here is a diff for examples/spawn_on_command:

Diff

diff --git a/examples/spawn_on_command.rs b/examples/spawn_on_command.rs
index 7b4c0b5..b42497d 100644
--- a/examples/spawn_on_command.rs
+++ b/examples/spawn_on_command.rs
@@ -242,10 +235,11 @@ fn update(
             let color = 0xFF000000u32 | (b as u32) << 16 | (g as u32) << 8 | (r as u32);
             properties.set("spawn_color", color.into());

-            // Set the collision normal
-            let normal = normal.normalize();
-            info!("Collision: n={:?}", normal);
-            properties.set("normal", normal.extend(0.).into());
+
+            // Set the collision rotation
+            properties.set("normal", Vec3::X.into());
+            effect_transform.look_at(transform.translation + normal.extend(0.0), Vec3::Y);
+            info!("Rotation = {:?}", effect_transform.rotation);

             // Spawn the particles
             spawner.reset();

barsoosayque avatar Sep 11 '24 22:09 barsoosayque