# How to Destroy Actor with all attached Actors?

**URL:** <https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE4, question, Blueprint\
**Created:** [October 13, 2017, 9:04am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916 "2017-10-13T09:04:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ning6566](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ning6566](https://forums.unrealengine.com/u/ning6566)\
**Post date:** [October 13, 2017, 9:04am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/1 "2017-10-13T09:04:38Z")

</div>

![216554-qq截图20171013170147.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/9/1/d912f83bb7c984a7638dd83b51e8f9e89d2c3444.png)

I want to destroy the actor 11 with all attached actors, how to do this in blueprint  
thanks

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 17, 2017, 9:37am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/2 "2017-10-17T09:37:45Z")

</div>

Something like this perhaps:

![216928-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/3/953e0b75f39bd77837f24299798e1a4d14d9a646.png)

---

<div class="post-metadata">

**Author:** ![LordArdiNugraha](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LordArdiNugraha](https://forums.unrealengine.com/u/LordArdiNugraha)\
**Post date:** [January 3, 2018, 11:11am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/3 "2018-01-03T11:11:02Z")

</div>

or simply you can destroyactor with “self” as target

---

<div class="post-metadata">

**Author:** ![error406](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@error406](https://forums.unrealengine.com/u/error406)\
**Post date:** [February 28, 2018, 5:32am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/4 "2018-02-28T05:32:52Z")

</div>

I was coincidentally trying to do it the same way as the above screenshot, but only certain actors (about half) were being removed. It seems that in the process of destroying the attached actors, it would automatically rename the existing actors which would throw off the GetAttachedActors array. To fix this, all I did was use a reverse ForEachLoop so ue4 wouldn’t rename things along the way and viola it works!

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [February 28, 2018, 3:39pm UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/5 "2018-02-28T15:39:05Z")

</div>

i dont think things would get renames its more that when you delete an item from an array the rest of the array data shifts. so if you delete index 5 then the index 6 would shift and become 5 creating a cascading affect. this is why reverse loops are perfect for removing data from arrays

---

<div class="post-metadata">

**Author:** ![error406](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@error406](https://forums.unrealengine.com/u/error406)\
**Post date:** [February 28, 2018, 11:25pm UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/6 "2018-02-28T23:25:46Z")

</div>

Thanks for clarifying that - that does make much more sense!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cbcd9794](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cbcd9794](https://forums.unrealengine.com/u/anonymous_user_cbcd9794)\
**Post date:** [November 6, 2020, 12:09am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/7 "2020-11-06T00:09:45Z")

</div>

I had an issue similar to this. In my case the enemy AI is a character and the weapon of the AI is made in a different Actor blueprint(Weapon\_Base). So I spawn these weapons to a socket on the enemy AI.  
Now here is the destroying part:

1. I destroy the enemy AI blueprint (with destroy self)
2. I promote the output of the spawned actor from class to a variable, and set this
3. Destroy the spawned actor by plugging it in another destroy node!

![321244-gag.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/4/9/549cf65833e999d67d32bb134afa340bb95fc023.png)

Now each time I kill the enemy AI, his weapon also gets destroyed.

Hope this helps you.

---

<div class="post-metadata">

**Author:** ![Gumax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gumax/32/562392_2.png) [@Gumax](https://forums.unrealengine.com/u/Gumax)\
**Post date:** [March 10, 2022, 5:05am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/8 "2022-03-10T05:05:47Z")

</div>

It worked perfectly. Thank you

---

<div class="post-metadata">

**Author:** ![Online\_Learner\_XWYN1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Online\_Learner\_XWYN1](https://forums.unrealengine.com/u/Online_Learner_XWYN1)\
**Post date:** [April 11, 2022, 3:46am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/9 "2022-04-11T03:46:26Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/4/5/645e338f870ae1095ee97c4d311e5cbce0516eac.png)  
get Attached Actor Changed in UE5

---

<div class="post-metadata">

**Author:** ![StefanKoopmans](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/stefankoopmans/32/484871_2.png) [@StefanKoopmans](https://forums.unrealengine.com/u/StefanKoopmans)\
**Post date:** [November 29, 2022, 9:29am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/10 "2022-11-29T09:29:17Z")

</div>

Is there a good reason for using for loops in this particular case? I like to keep it simple 😉

![destroy_actor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/5/4/b5400273d7d0c88b6fc3015a9e2d4ea63e7fcf0c.jpeg)

---

<div class="post-metadata">

**Author:** ![TLOA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tloa/32/634422_2.png) [@TLOA](https://forums.unrealengine.com/u/TLOA)\
**Post date:** [March 22, 2023, 9:49pm UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/11 "2023-03-22T21:49:09Z")

</div>

I would like to pay you. Been searching and fighting with this for WEEKS.

---

<div class="post-metadata">

**Author:** ![Gelmir\_Telperien](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gelmir_telperien/32/752351_2.png) [@Gelmir\_Telperien](https://forums.unrealengine.com/u/Gelmir_Telperien)\
**Post date:** [November 19, 2023, 11:52pm UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/12 "2023-11-19T23:52:28Z")

</div>

For some reason, it doesn’t get all actors for me?!? it removes some, but not all?? Only when I run it multiple times does it work? even tried adding garbage collection node but no luck.

---

<div class="post-metadata">

**Author:** ![Gelmir\_Telperien](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gelmir_telperien/32/752351_2.png) [@Gelmir\_Telperien](https://forums.unrealengine.com/u/Gelmir_Telperien)\
**Post date:** [November 19, 2023, 11:53pm UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/13 "2023-11-19T23:53:47Z")

</div>

Get all actors of class works, but get attached actors fails

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [November 20, 2023, 2:16am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/14 "2023-11-20T02:16:54Z")

</div>

my guess would be when you destroy something on a loop it breaks the loop, for instance if you destroy index 2, index 3 becomes index 2 and gets skipped.

you can try a reverse loop or try caching the actors to destroy in a local variable

---

<div class="post-metadata">

**Author:** ![TLOA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tloa/32/634422_2.png) [@TLOA](https://forums.unrealengine.com/u/TLOA)\
**Post date:** [November 21, 2023, 4:08am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/15 "2023-11-21T04:08:29Z")

</div>

Did it not work to promote all attached actors to vars and destroy rhose vars after the primary actor destroys? Works like a charm for me! My setup isnt overly complicated tho.

---

<div class="post-metadata">

**Author:** ![Gelmir\_Telperien](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gelmir_telperien/32/752351_2.png) [@Gelmir\_Telperien](https://forums.unrealengine.com/u/Gelmir_Telperien)\
**Post date:** [November 22, 2023, 6:19pm UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/16 "2023-11-22T18:19:24Z")

</div>

Sounds possible. I noticed it would skip every second index. For now my other method, get class works like a charm. It’s the exact same setup, but using the get all actors of class instead of get attached actors.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [November 23, 2023, 5:35am UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/17 "2023-11-23T05:35:06Z")

</div>

get all actors could be problematic, for instance it could get attachments off a different actor.

i think the best way to handle it is have the child actor bind to its parents ondestroyed event and then destroy itself.

that way its self contained and modular

---

<div class="post-metadata">

**Author:** ![Gelmir\_Telperien](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gelmir_telperien/32/752351_2.png) [@Gelmir\_Telperien](https://forums.unrealengine.com/u/Gelmir_Telperien)\
**Post date:** [November 26, 2023, 6:50pm UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/18 "2023-11-26T18:50:35Z")

</div>

True, but for now it’s not a problem. I will worry about it later. Only annoyance I have is that the actor names do not reset to 1 and have numbers such as 834. I use Spawnactor.

Here is an image of my current results, I use procedural mesh section to create a hexagon planet. I still have to do the normals and uv’s:

 ![image_2023-11-26_194914847](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/6/c/66c4bb464c177caf08bbe9a425e6a3bf28f82878.jpeg)

---

<div class="post-metadata">

**Author:** ![Gelmir\_Telperien](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gelmir_telperien/32/752351_2.png) [@Gelmir\_Telperien](https://forums.unrealengine.com/u/Gelmir_Telperien)\
**Post date:** [December 3, 2023, 8:07pm UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/19 "2023-12-03T20:07:46Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/6/b/b6bfcf312529bd686d9555a486a65ad7e734a267.png)  
anyone wondering, this is the solution. Like BP\_SpawnGato metioned.

---

<div class="post-metadata">

**Author:** ![Kndrzej](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kndrzej](https://forums.unrealengine.com/u/Kndrzej)\
**Post date:** [June 16, 2024, 8:25pm UTC](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916/20 "2024-06-16T20:25:58Z")

</div>

This worked for me

[Next page](https://forums.unrealengine.com/t/how-to-destroy-actor-with-all-attached-actors/406916.md?page=2)
