How to prevent screen space UI elements from moving with the player?

I’m trying to implement floating damage numbers and I’ve implemented the following example, but the damage numbers move with the player. I want them to stay where they were when initially rendered. Is that not possible with screen space UI elements?

Initially I was using widget components and attaching one on damage, but those move with the AI. I just want them to stay where they were initially rendered. Does anyone have any ideas on how to implement this properly?

Can you just spawn a blueprint with a widget component in it?

Either use a component as suggested above - the comp will update the widget accordingly; or set widget position in viewport every frame yourself.

So a widget component in world space instead of screen space? I tried that, but had issues getting it to display on top of everything properly; maybe I’m missing a setting somewhere to fix that? Screen space just follows my screen as I move.

  • widget components in Screen Space are z-sorted automatically and follow their actors:

But since it’s screen space, they render on top of any geometry.

  • they’re also z-sorted in World Space mode, ofc:

But the quads they render on do not rotate to face the camera. There’s a couple of ways to make this happen, ofc.


You can also disable occlusion:


I tried that, but had issues getting it to display on top of everything properly; maybe I’m missing a setting somewhere to fix that? Screen space just follows my screen as I move.

Perhaps you could demo the undesired behaviour and produce and example of how you’d like to them to behave?


If you did not want to use a widget component, the actor can shift them around with something similar to this pseduoscript:

This would need to be done every frame and can be written better, ofc.

I know. I don’t want them to. I want to display the floating damage numbers above the actor that was hit, but I don’t want them moving with the actor.

Basically I just want the damage numbers to float above the actor at the point of impact. If that actor moves I do not want the damage numbers moving with them, which is the case for my floating healthbars and is the desired result. I guess I could make the numbers fade even faster so it’s not too noticeable that they’re moving with the hit actor, but still feels weird.

Would using World based instead of Screen based widget be the solution here? My only issue with World based is it didn’t have the z-sorting that screen space has or I could have missed that configuration somewhere.

I tried this and the numbers move on the screen as the player moves.

Decided to just stick with attaching widget components. Once I added some movement to it it’s fine that it follows the hit actor. Below is what I have.

Widget Class


Then when the AI is hit I just call the below.

image

Seams to work well enough.

Went a step further and completely eliminated tick on the component. Moved the movement behavior to the widgets tick.

Component

Widget

Wonder if it’s possible to do the movement via animation against the translation and if that’d be better than using tick directly.