# Evenly distribute/split homing projectiles between multiple enemies

**URL:** <https://forums.unrealengine.com/t/evenly-distribute-split-homing-projectiles-between-multiple-enemies/1282837>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [September 4, 2023, 3:01pm UTC](https://forums.unrealengine.com/t/evenly-distribute-split-homing-projectiles-between-multiple-enemies/1282837 "2023-09-04T15:01:11Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [September 4, 2023, 4:08pm UTC](https://forums.unrealengine.com/t/evenly-distribute-split-homing-projectiles-between-multiple-enemies/1282837/2 "2023-09-04T16:08:00Z")

</div>

First you need to get all enemy actors, and sort them by distance.

Old topic about it (i recommend C++ code):

> [@How do I sort an array by distance?](https://forums.unrealengine.com/t/how-do-i-sort-an-array-by-distance/410764):
>
> Hello, I’m creating a third person shooter game and I want my companions to follow me in a V Formation. I have gotten the formation already but the function that I used to sort the companion array by distance is not working well. Because the formation is symmetrical, when the player continues to move in the same direction, the two companions beside it maintain the same distance from it, hence the function tends to resort the array and make the two companions swap sides. I have tried sorting the…

when you have that sorted by distance array. Shoot those projectiles in order.  
When there are left, go for second loop.

---

_[View the full topic](https://forums.unrealengine.com/t/evenly-distribute-split-homing-projectiles-between-multiple-enemies/1282837)._
