Download

How do I destroy an added component?

I’m trying to create a mirror that reflects a a beam of light when pushed into another beam of light. This is done with some sort of add component command I don’t know the name of because I found it by dragging a static mesh into the Blueprint Graph, which then executes a Set command to give a name to the new component called “Light Ray”. Right now, the other “beam of light” is just a box component of a non-functional Blueprint while the “reflected light” is a static mesh (specifically, a 50x500 pillar). That’s all working fine as far as I can tell, but the problems starts when I try to move the mirror out of the light.

I also want the mirror to stop producing light when the mirror leaves the other beam of light. Right now I’m using an End Overlap event to trigger a Destroy Component command which targets the aforementioned Light Ray component with a Get function. This seemed to work without incident in 4.4, but in 4.5 it doesn’t. As far as I can tell, the Destroy Component command still works on components that the Blueprint starts with (such as the mirror itself) but completely ignores Light Ray.

What do I do about this? I suppose I could have it start with Light Ray and then destroy it when play starts, or transform the static mesh when triggered instead of adding and destroying it, but that seems kinda sloppy to me. Is there a way to get Destroy Component to work on added components?

Hello,
maybe that instead of destroy you can set the visibilities ( and collision when needed) of your “light ray” (and other components)

Actually, the problem turned out to be something else entirely. The Begin Component Overlap event that creates the Light Ray was being triggered twice for some reason, creating two Light Rays whereas the Destroy Component command could only delete one of them. I managed to fix it with a Branch, so now it only creates one Light Ray.

Thanks anyway.