Evenly distribute/split homing projectiles between multiple enemies

This.

Assign the target as they are spawned. Notice the end result was an array of actors and an array of integers; the int array has distributed the amount to spawn and the reference array the target that correspon to each amount.

This should be in the class that spawns. The only job for the projectile is to navitage to the target.


Idealy you can save yourself the int array and spawn them in that loop. It was done mainly for debug… but it works either way. There are also better sorting algorithms you can go for, @Nawrot shared a priceless link for that. From that link check out shell sort.

1 Like