How to get pawn pointer in widget blueprint

Hello

I’ve got a widget blueprint which is used as a widget component inside an actor, which is meant to display it’s health with a progress bar. How can I get a pointer/reference to the actor which’s component this blueprint actually is (picture)?

I’ve only found a way to get player’s pawn, which I don’t want here, as the health bar appears above npcs too.

229569-ue4.png

By saying “pointer/reference to the actor” I mean anything like pawn / character / etc I can cast to “Archer” (on pic) parent class

GetOwner does not work on Widgets. You will either need to pass in a reference to the parent actor through some kind of initialise function with the widget, or have the actor itself call other functions on the widget itself.

What exactly are you aiming to do?

You can use Get Owner. It will return the Actor owning that component.

This is not a Widget but a Widget Component and Get Owner works perfectly with it.

Unfortunately Get Owner does not compile in widget blueprint (it says like “this is not an actor”)

Then I have misunderstood your question. I thought you wanted somehow to get the owning actor of the widget component, but it looks like you are trying to do something different. Can you explain again what your are trying to achieve and what your problem is.

Sorry you were right @Dune, the OP was trying to access the owning actor from the widget. Get Owner doesn’t indeed work in this case.
.

The idea is for many different widget blueprints (used as widget components) to get the pawn they are components for, and use some data from it to update itself.
I don’t really want the pawn to set the data in widget with some functions, becouse I would have to create many blueprints of the same actor, just to handle widgets with different logics.

Check this out. It offers a couple of suitable solutions.

Thats much less logics in character blueprint, I think I’m gonna use it till I find better solution, thanks!