Download

How to get a BP Component to reference the actor it's applied to?

I’m creating a BP component that I can apply to some of the static meshes in my level to make it so they can be interacted with. The component will add basic behaviors such object outline highlighting, showing a menu when clicked, etc.

I have this all working except that I can’t figure out how to get a reference to the actor that the component is applied to. I’ve worked around it by adding a public variable to the blueprint and explicitly setting the actor that way. But it would be much better if I can get the component to reference the actor it’s applied to - is there a way to do this?

Thanks.

Essentially I want to be able to change this bit of my component so that ‘ThisActor’ references whatever actor the component is applied to;

BPComponent.jpg

Are you after the GetOwner node?

Yes! Thank you! I knew there would be a node that did what I wanted, I just could not find it in the documentation. Many, many thanks :smiley:

My BP now looks like this;
16d5bcbc0f0f95774f2eac79cdb129edb1b894ed.jpeg

Please let me know if that actually works or not. If so, that means that my original idea from a year ago could become a reality. Giving an Actor life.

Yes, it’s working for me in my particular instance. I can now add a single BP component to any mesh in my scene to enable it as a ‘usable’ object. I’m now working on ways to differentiate between types of usable objects.

Thats a fairly common way you will want to work when you are using child and parent blueprint actors.

Its still not working, i have a tank and it cast the track instead of the hull, and the hull is the parent so whats going on ?