# How do I split AddUnique array - to Play Anim Montage once per index?

**URL:** <https://forums.unrealengine.com/t/how-do-i-split-addunique-array-to-play-anim-montage-once-per-index/1153758>\
**Category:** Blueprint\
**Tags:** foreachloop, unreal-engine, Array, question\
**Created:** [May 4, 2023, 3:03am UTC](https://forums.unrealengine.com/t/how-do-i-split-addunique-array-to-play-anim-montage-once-per-index/1153758 "2023-05-04T03:03:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![XxNotAGamerxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxNotAGamerxX](https://forums.unrealengine.com/u/XxNotAGamerxX)\
**Post date:** [May 4, 2023, 3:03am UTC](https://forums.unrealengine.com/t/how-do-i-split-addunique-array-to-play-anim-montage-once-per-index/1153758/1 "2023-05-04T03:03:42Z")

</div>

UE4.27  
Please help with the logic nodes. I do not understand how to process/split AddUnique arrays, to do something once per index, then remove that index so it can’t be used in the Loop again.

I tried [Do once] or [Removing indexes] after they get to the [Play Montage Node]. But the Loop (or #2: a re-triggering of the tick ANS \> Event) is still making each Character in the array, Play the anim twice instead of only once.

- [Details at steps 5, 7 below] ![5 CharBP - BPI Event called - go in Hit Function next - then out to Play montage code](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/f/13f2b3d3c2b9fce2a07a1e39d8f8d357a5a4234f.jpeg)

Goal:

- I have a spinning leg-sweep-attack, thus the same enemy can be hit twice during the same attack. And multiple enemies can be hit by the same AOE attack.

- But since I play a fall-down animation on any enemy that is hit, then it would look weird to play it twice (once enemy is already falling – no need to play it again).

- Thus I want to play the anim ONCE on EACH unique enemy, for this Sweep attack;

- 
  - but I want the Bool logic to be able to repeat-play anims for different attacks like Chest hit – if the SAME enemy is Hit many times. (So I want a way to toggle the AddUnique logic off/on.)

Setup:

1. In Anim Montage, I added a Notify State that is set to Tick (default Epic Function), meaning it will retrigger for the entire time duration that I choose (0.6 secs).  
 ![1 Anim Montage - ANS duration](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/1/9b104396aec1f9477b6ae92df0534d335aa096e2.png)

- (Also in my pic, I don’t remember why I have PlayMontageNotify – or the connected logic. It may be from an old version I was working on.)

1. This **Anim Notify State** constantly calls an Event in CharBP (using BPI).  
 ![2 ANS - calls BPI in CharBP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/9/3f96f2204016d5d79278e426bedd1462a6f21bb5.png)
2. CharBP has the code for Player (input \> keypress \> loads a DataTable that decides which variables to use for attack anim, which matching anim to play on Enemy, which bones for Hit trace, etc).

- Enemy is a child of CharBP. Thus Player’s CharBP is where Hit Enemy is told which anim to play and when – by populating the ‘Hit Character variable’ that is in Player’s CharBP.

1. So Player CharBP \> Keypress \> loads DT \> says which Anim Montage to play \>

- 4b. \>\> Triggers **ANS** in Anim Montage \>
- 4c. \>\> which **triggers BPI Event call back in CharBP** \>
- d. \>\> **to perform Hit check** \> to decide which Enemies to **play reaction anim on**.

* * *

1. So back in CharBP, the BPI Event starts [Pic5, part A] \> goes to a Function that calculates hits.  

2. In the Hit Function, I collect single hits that are “Characters,” and put each Unique character into an array. And I Set this array as a Variable to output from the function.  

3. Back in the CharBP graph [Pic5, part B]: I feed the Unique Character array into a ForEach Loop (or how else can I split the array into single Characters?)

4. At the Branch [Pic5, part B], I want the bottom False-path to have logic to only play the Anim Montage ONCE, on EACH Character [Pic5, part C].

5. At the top True-path, I want the logic to play [a different Anim] on the SAME Character, many times, for EACH time a hit was registered on him (thus I would need an option to not use the AddUnique array, in the function at #6).

6. (Then after each Character plays the anim, I can clear the Array/Characters, since they are unneeded – the attack finished. If I attack again, I will determine fresh Hits that are still in range.)

7. But I don’t know the nodes to use for #8. Please help, ty.
