How do I make each individual child actor to have different targets for projectiles spawn from them?

Basically, think of it as a RTS game.
You have a group of units selected, RMB to attack on a single enemy.

Currently, I can get enemy targeting to work.
However, this targeting automatically gets applied to all instances of my units, instead of just the units that are in selected array having the targeting applied.

Any ideas where I can improve ?

Blueprint for Actor

Blueprint for Player Controller

Blueprint for HUD

Hi @Starcraftsui,

Check with small number of units weather your selection adequately fills the selected units array and more importantly weather its correctly cleared afterwards.

The clear here only ensures that only one enemy is selected every time.

Basically a selection array that always only selects one unit because I am using the same function as my click and drag functions.

I didn’t get that…

So you are sure that the Selected Units Array has the correct actors in it? Then what do you actually mean by “targeting is applied”? Which is the node that applies targeting?

P.S.
I would probably store the selected units in the controller instead of taking them from the HUD.

This node is for targeting.
RMB on enemy unit, then they are selected.

Steps should be:

  1. Select your unit (A)
  2. Click on enemy
  3. enemy selected as target
  4. your units will fire on enemy.

Currently,

  1. You can Select your unit (A)
  2. Click on enemy
  3. enemy selected as target
  4. your units will fire on enemy.

However, without being first selected in step 1, Unit B will now also target this enemy as it is the same child actor. All copes of the same child actor will have the same enemy set as target too.

You have Array Selected Units:

  1. Check if it is set correctly.
  2. Check if it is cleared correctly.
  3. Check if it contains the correct units.
  4. Move this array out of the HUD and into the Player Controller.

P.S.


The server should never access the HUD. Move everything gameplay related out of the HUD and into the controller.

I’ve figured out how to do it by adding a “Cast To”.
Perhaps what I’ve been doing it previously kept it perpetually in HUD.