Destroy component from another blueprint

Hi all,

so as the title says, I’d like to destroy a component. There is of course the “destroy component” node, but if you look at the documentation for it, it says:

The blueprint I’m calling the node from is different than the one that contains the component I want to destroy.

So how would I destroy a component of another blueprint?

Lets say you want to destroy a component of Blueprint A from Blueprint B. You could create a function in Blueprint A that does Destroy your wanted component. Then, from Blueprint B, you call that function on your object of class Blueprint A to do the job.

If there is more “specification” on what you want exactly to do, you can add them here and I could have a better answer :slight_smile:

I think this is what I need, thank you
.

But there are multiple components that will be deleted coming from multiple blueprints, I don’t think it would be a good idea to add that function to every single blueprint.

Is there another way?

Can you explain your problem in more specific terms? What are you trying to accomplish exactly? From my perspective, deleting a component from an actor should always be accomplished by it’s owning actor, so give me more details on the system you wish to put in place and I may be able to help further!

Basically any component that comes into a certain range I want to delete. I’ve figured it out though, and I will post it as an answer.

Thanks for the help though!

Alright,
so what you want to do is call the destroy component function as the blueprint that has the child component.
This can be done in multiple ways.
You can cast to the blueprint that has the child component you want to delete and then delete it through that, by using the “as blueprint_[Blueprintname]” and wiring it into the object.

Alternatively if you already have the actor with the child component referenced you just wire it into the object node like this:

1 Like

My Destroy Component Node only has a Target input. I guess the Object input has been removed. How do you destroy a Component from another Blueprint now?

Ok, I just created a Custom Event on the component, which calls the Destroy Component function on itself. For me that is a decent solution since I always want to destroy the same component on different actors.

@anonymous_user_57689c7d - That worked for me as well. If I would call Destroy Component directly a warning “Could not destroy component” would happen.
Do you think it’s safe to meddle with the components during the components tick?

Yes, that should be safe, just make sure you do not call other functions with the destroyed component, as the destroyed component should be invalid after calling destroy component.

Plot twist, what if blueprint A is blueprint B?.. I have two of the same actor classes and when I spawn the second one I want it to destroy a component of the first one.