Issue with setPositionInViewport

Hey there.

I am using set position in viewport to create a healthbar that is always floating over my character. Everything works like a charm with my blueprint graph, but as soon as i zoom in too close with my camera the widgets are too far out of bounds and they get hidden when they are out of screen.

That would be cool, but as soon as i zoom out i cant do anything to show them again.
Help would be appreciated.

here is my graph


Have you considered using widget component for your actor? That way it will always be the same size if you set “Space” to “Screen”.

Mhm… I haven’t considered it. Those widgets are being attached to the camera.
If nothing else works i will consider it. Still i am curious why the widget dissappears and does not want to render anymore if its out of bounds. I was thinking to limit the bounds… But its not the best idea either. Is there some function I can call to make it render again? Its not like its getting destroyed - i tried to trigger event on destruct but it didnt trigger.

Have you used say print string to debug? Check what screen location is being outputted?

EDIT: I think player viewport relative should be unticked unless you’re doing a splitscreen game but correct me if I’m wrong.

Yeah it keeps updating, and then once it hits the threshold that the object disappears it stops updating and keep printing same value. There is nothing special about the value tho. Its still within reason
< 500 > -500

Can you show what happens next in your BP?

Maybe the way i am creating it is wrong…
I dont know i am storing it variable

I fixed it by clamping the output position…
I find if the output position is bigger then viewport size + 50px or smaller -50px then something happens to the widget and it dissapears…

My solution is probably not ideal but it works for now…

Any comments?

It’s not working because the widget that’s not in the screen space does not Tick. Once it’s out and set to Hidden, its own tick cannot show it up again.

That’s why your last method works, the widget never goes out of screen and always Ticks. This is actually useful for screen edge indicators, like incoming damage or direction indicator.

Ideally, you want to do the Tick set position tracking in the actor owning the widget, not in the widget itself - it’s too unreliable. You already create the appropriate widget reference - use it to track the widget. You could probably even skip setting visibility then.

Also, consider adding comments to an answer rather than adding a new answer - it will make it easier for others to keep track.