Destroy Component not working

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.

i also tried this to no avail

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.

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.

Did you try what I suggested?

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

Is your component a UChildActorComponent?

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

There are no UChildActorComponents, they are normal blueprint actors.

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

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

I don’t understand. Which node is broken?

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

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

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

Hi Taisaku,

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

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?

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!

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:

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

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

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

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.

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.

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