Selection Rectangle Decal Visable While Within

I am making an RTS and am trying to apply a decal to units within a selection rectangle.

This is prior to the units being selected and is to signify the units are within the rectangle.

Currently, the Get Actors In Selection Rect works great, and actually selecting the units upon mouse release is fine- however I have a secondary decal that is to signify not selection but simply whether the unit is within the rectangle, and while I have been successful in making this decal viable upon overlap with the rectangle, I have NOT been able to figure out how to remove the decal upon the unit leaving the rectangle.

Basically once the decal is made visable it stays visable until the mouse is released, regardless as to whether it is still within the rectangle.

All help is appreciated.
Thank you!

You need to fill a variable array of class “Actor” from the GetActorsInSelectionRect.

And from this array, you iterate over it with a foreach, you enable the decal (you need to cast to your unit type first).

Now the trick:
Before getting all actors in selection rect, you ask if the array Length is != 0.
If true (with a branch), you first iterate over this array and deactivate the decal.
On Complete, you clear the array and proceed with your GetActorsInSelectionRect path.
From the false of the branch, you just proceed to the GetActorsInSelectionRect, without doing anything with the array.

2 Likes