How do I get my screenspace widget to show up more consistently


Here is what my ItemCard widget looks like up from a distance of a few feet, and its pretty much fine.

When I move closer to the pickup, the widget moves to the right. It should be getting drawn where the center of the camera hits either of the red outline, and it worked fine in WorldSpace. How do I get screenspace to work instead?

  • are you using a widget component? Almost certain you do since you mention world space, too. Just double checking.
  • or is this just a widget? If so, how is it being tracked?
  • do you have a canvas in that widget? If so, can we see the widget hierarchy?

Yeah its a widget component, here’s the widget being drawn


there is a canvas, its scaled to the size of the vertical box that contains the info

I’d start by removing the canvas. It’s redunant, and can offset layout (we can’t see the whole thing in the pic, hard to tell). Right click it in the hierarchy and replace with child.

The desired size will be dicated by the component anyway.

How is the actor hierarchy, how is the component attached? Is there any relative transform applied?


after removal of canvas, havent changed desired size or anything yet

image
Here’s the hierarchy


Location code, I assume it just spawns it based on the location of the root so the widget component will have the same location

Also I’m essentially trying to recreate the Borderlands 2 item cards if you’re familiar with those

Is the behaviour correct now when you get further and closer? Size can be punched into the component directly.

It looks like its the same


actually this is definitely less centered than it was before but thats probably an easy fix?


This is what it looks like closer

Is there like a generally done method of doing screenspace widgets like this

While it’s not a method I’d use, it should work OK for this. At default settings:

  • widget:

image

  • component:

  • in the player:

I wonder what else you’re doing we don’t know about.

2 Likes

Thanks this definitely is a huge improvement. I think all I need to do now is adjust where its being drawn, I’ll lyk how it goes. Tysm

i think the issue was the RootComponent

1 Like

Three options come to mind:

  • offset the component inside the card actor
  • offset the location when you spawn the card actor
  • offset the widget itself using a slot, like this Overlay, for example:

I can see all 3 methods working.


If you ever look for an alternative method:

Assuming you only want 1 card visible at a time, I’d:

  • override the widget component:

image

  • in said component:

  • in the player:

The idea is that the player carries the component with them, and they can attach it to another actor and show it. This way you do not need to spawn and destroy actors. We reuse the same comp.

1 Like

Very good ideas, thank you! My issue with the draw location now is just due to the fact that its drawn at the location on a vertical line that is closest to the hit of a raytrace on the red outlines, which causes huge inaccuracy from angles that are closer to parallel to the vertical line, basically what I need to do is find a vector equation that, given lines A and B, finds point on line A that is closest to B.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.