no move for orphan balls

This commit is contained in:
nquidox 2026-04-12 16:39:23 +03:00
parent 0fd5719473
commit 6423764a17
4 changed files with 74 additions and 6 deletions

View file

@ -108,7 +108,6 @@ pub fn move_projectiles(
}
}
const HIT_THRESHOLD: f32 = SLOT_SIZE;
pub fn detect_projectile_hit(
mut commands: Commands,
track: Res<TrackPath>,
@ -186,6 +185,21 @@ pub fn detect_projectile_hit(
slot_progress: target_progress,
}
}).remove::<BallProjectile>();
if let Some(&curr_pos) = track.points.get(insert_idx) {
// Вычисляем позицию: интерполяция или центр слота
let visual_pos = if let Some(&next_pos) = track.points.get(insert_idx + 1) {
curr_pos.lerp(next_pos, target_progress)
} else {
curr_pos
};
// Обновляем Transform: ставим на трек и выравниваем Z (10.0),
// чтобы шарик не висел «над» очередью (PROJECTILE_Z_INDEX)
commands.entity(proj_entity).insert(
Transform::from_translation(visual_pos.extend(10.0))
);
}
// запоминаем индекс слота, куда попали
wave.last_insert_index = Some(insert_idx);
}