# Destroy Component not working

**URL:** <https://forums.unrealengine.com/t/destroy-component-not-working/317594>\
**Category:** World Creation\
**Tags:** Destroy, unreal-engine, Physics, Components, question\
**Created:** [May 6, 2015, 3:38am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594 "2015-05-06T03:38:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Neros](https://forums.unrealengine.com/u/Neros)\
**Post date:** [May 6, 2015, 3:38am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/1 "2015-05-06T03:38:18Z")

</div>

4.7.6

trying to replace a weapon object which is attached as a child to ‘weapon slot’ scene coponent

but calling ‘Destroy Component’ doesn’t destroy anything, leaving me with multiple weapon objects in same slot.

 ![41522-destroy.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/3/aa352c62e9dbc3a001b63a01aa29638ac773b4e0.png)

i also tried this to no avail

 ![41523-destroy2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/5/1/75150da6e1c0257f0b445030a99f646f36c8aa4d.png)

---

<div class="post-metadata">

**Author:** ![Emidee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emidee](https://forums.unrealengine.com/u/Emidee)\
**Post date:** [May 6, 2015, 5:57am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/2 "2015-05-06T05:57:56Z")

</div>

Are nodes attached to ForEachLoop get called at all?

I think you should use second graph, but connect Detach and Destroy actor nodes directly to node ForEachLoop is connected to, and then attach spawn + attach to Destroy node.

Moreover, I’m not sure this is a good pratice (idea?) to clear dynamically parent actor components.

---

<div class="post-metadata">

**Author:** ![Neros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Neros](https://forums.unrealengine.com/u/Neros)\
**Post date:** [May 6, 2015, 9:53am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/3 "2015-05-06T09:53:14Z")

</div>

loop nodes do get called in both cases. In first case node is called but nothing changes. In second case actor is detached but is not deleted.

---

<div class="post-metadata">

**Author:** ![Emidee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emidee](https://forums.unrealengine.com/u/Emidee)\
**Post date:** [May 6, 2015, 10:09am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/4 "2015-05-06T10:09:46Z")

</div>

Did you try what I suggested?

---

<div class="post-metadata">

**Author:** ![Neros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Neros](https://forums.unrealengine.com/u/Neros)\
**Post date:** [May 6, 2015, 10:18am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/5 "2015-05-06T10:18:31Z")

</div>

you cant attach a ‘Destroy Actor’ node to a Scene Component

---

<div class="post-metadata">

**Author:** ![Emidee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emidee](https://forums.unrealengine.com/u/Emidee)\
**Post date:** [May 6, 2015, 10:20am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/6 "2015-05-06T10:20:11Z")

</div>

Is your component a UChildActorComponent?

If so, can’t you destroy ChildActor of this component?

---

<div class="post-metadata">

**Author:** ![Neros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Neros](https://forums.unrealengine.com/u/Neros)\
**Post date:** [May 6, 2015, 10:24am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/7 "2015-05-06T10:24:31Z")

</div>

There are no UChildActorComponents, they are normal blueprint actors.

---

<div class="post-metadata">

**Author:** ![Emidee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emidee](https://forums.unrealengine.com/u/Emidee)\
**Post date:** [May 6, 2015, 10:33am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/8 "2015-05-06T10:33:28Z")

</div>

At first, you just spawned a weapon (actor) and attached it to your player (I guess) at a specific socket, right?

If so, you could store weapon actor in a variable, and when you wish to change, you call DestroyActor on this variable, spawn new weapon, attach it, and update variable.

You shouldn’t have to use / delete WeaponSlot if I understood right

---

<div class="post-metadata">

**Author:** ![Neros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Neros](https://forums.unrealengine.com/u/Neros)\
**Post date:** [May 6, 2015, 10:47am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/9 "2015-05-06T10:47:11Z")

</div>

There are a few workarounds i could use, but point is node is broken.

---

<div class="post-metadata">

**Author:** ![Emidee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emidee](https://forums.unrealengine.com/u/Emidee)\
**Post date:** [May 6, 2015, 11:35am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/10 "2015-05-06T11:35:10Z")

</div>

I don’t understand. Which node is broken?

Could you also validate I understood your problem right? (my previous comment)

---

<div class="post-metadata">

**Author:** ![Neros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Neros](https://forums.unrealengine.com/u/Neros)\
**Post date:** [May 6, 2015, 12:03pm UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/11 "2015-05-06T12:03:01Z")

</div>

‘Destroy Component’ node is broken in this situation.  
I’m not sure what you mean about understanding my problem, it seems you do.

---

<div class="post-metadata">

**Author:** ![Emidee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emidee](https://forums.unrealengine.com/u/Emidee)\
**Post date:** [May 6, 2015, 12:07pm UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/12 "2015-05-06T12:07:34Z")

</div>

I don’t have any other answers to give you apart from what I already told you:

don’t destroy component but destroy actor you attached to it, and then spawn a new actor

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33800a51](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33800a51](https://forums.unrealengine.com/u/anonymous_user_33800a51)\
**Post date:** [May 6, 2015, 9:49pm UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/13 "2015-05-06T21:49:18Z")

</div>

Hi Taisaku,

Can you show me how you’re attaching child Actor to Scene Component? Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33800a51](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33800a51](https://forums.unrealengine.com/u/anonymous_user_33800a51)\
**Post date:** [May 6, 2015, 10:00pm UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/14 "2015-05-06T22:00:50Z")

</div>

Oh, I apologize, it looks like you’ve done that already. So you’re spawning an Actor, attaching actor to your Scene Component? Doing same thing, Destroy Component is working for me. Does this happen in a new project as well as your current project?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33800a51](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33800a51](https://forums.unrealengine.com/u/anonymous_user_33800a51)\
**Post date:** [May 6, 2015, 10:08pm UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/15 "2015-05-06T22:08:50Z")

</div>

I apologize again, I AM seeing same thing with a similar setup. Let me investigate a little further and I’ll get back to you with what I find. Thanks for your patience!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33800a51](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33800a51](https://forums.unrealengine.com/u/anonymous_user_33800a51)\
**Post date:** [May 6, 2015, 10:20pm UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/16 "2015-05-06T22:20:35Z")

</div>

Okay, I think I found answer. reason it’s not deleting is because you haven’t actually added it as a component. Instead, you’re spawning an actor and attaching it to a component, which does not actually turn it into a component.

Here’s a basic setup that reproduced problem you’re having (with some delays in there so we can see it happen:

 ![41665-destroycomponentwrong.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/5/c/35c17da14f1f862f999980a84e9ae88c2aa0b274.png)

Instead, use Add Child Actor Component and set desired Actor in details panel, and use Attach To for Scene Component:

 ![41666-destroycomponentcorrect.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/b/f/4bf171a74bcce1e4fa65e636240116fb8aa75bee.png)

Hope that helps! Let me know if you have any questions.

---

<div class="post-metadata">

**Author:** ![Neros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Neros](https://forums.unrealengine.com/u/Neros)\
**Post date:** [May 7, 2015, 12:09am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/17 "2015-05-07T00:09:39Z")

</div>

That will just attach a blank ChildActor to my WeaponSlot, how do i tell it what class of blueprint to spawn?

---

<div class="post-metadata">

**Author:** ![Neros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Neros](https://forums.unrealengine.com/u/Neros)\
**Post date:** [May 7, 2015, 12:16am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/18 "2015-05-07T00:16:25Z")

</div>

When you ‘Attach Actor to Component’ it should still be an actor, yet ‘Destroy Actor’ doesn’t work because you can’t retrieve a list of attached actors, only a list of attached components. Something in there is mislabeled or has some unexplained functionality.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33800a51](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33800a51](https://forums.unrealengine.com/u/anonymous_user_33800a51)\
**Post date:** [May 7, 2015, 12:46am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/19 "2015-05-07T00:46:24Z")

</div>

Sorry, can’t be super thorough with my answer at moment because I’m not at work, but…

Look in Details panel for Add Child Actor Component node, and it lets you select Class you want to use.

---

<div class="post-metadata">

**Author:** ![Neros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Neros](https://forums.unrealengine.com/u/Neros)\
**Post date:** [May 7, 2015, 12:48am UTC](https://forums.unrealengine.com/t/destroy-component-not-working/317594/20 "2015-05-07T00:48:06Z")

</div>

I found it in details panel, but it’s not a variable.

[Next page](https://forums.unrealengine.com/t/destroy-component-not-working/317594.md?page=2)
