From 2846c047654c6aa5af7e6aa3b521909e2835e840 Mon Sep 17 00:00:00 2001 From: Jonas H Date: Thu, 2 Apr 2026 19:55:50 +0200 Subject: [PATCH] velocity for projectiles --- src/systems/dialog_system.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/systems/dialog_system.rs b/src/systems/dialog_system.rs index b75dc5e..34c34d5 100644 --- a/src/systems/dialog_system.rs +++ b/src/systems/dialog_system.rs @@ -177,11 +177,23 @@ fn tick_displaying_bubbles(world: &mut World, delta: f32) .with(bubble_entity, |t| t.position) .unwrap_or(Vec3::ZERO); + let player_entity = world + .player_tags + .all() + .into_iter() + .next() + .expect("no player entity"); + let player_pos = world + .transforms + .with(player_entity, |t| t.position) + .unwrap_or(Vec3::ZERO); + + let velocity = player_pos - bubble_pos; + let projectile_entity = world.spawn(); - world.transforms.insert( - projectile_entity, - Transform::from_position(bubble_pos), - ); + world + .transforms + .insert(projectile_entity, Transform::from_position(bubble_pos)); world .names .insert(projectile_entity, "DialogProjectile".to_string()); @@ -192,6 +204,7 @@ fn tick_displaying_bubbles(world: &mut World, delta: f32) bubble_entity, correct_parry, parry_window_open: false, + velocity, }, );