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

**URL:** <https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712>\
**Category:** Blueprint\
**Tags:** unreal-engine, Widget, Blueprint, question, UMG\
**Created:** [January 2, 2023, 8:30pm UTC](https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712 "2023-01-02T20:30:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krileon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Krileon](https://forums.unrealengine.com/u/Krileon)\
**Post date:** [January 2, 2023, 8:30pm UTC](https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712/1 "2023-01-02T20:30:31Z")

</div>

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?

> [@Damage displayed](https://forums.unrealengine.com/t/damage-displayed/99716/3):
>
> Or use a widget: The widget is quite plain. You can add colours, crit sfx, alter font size, add outlines and so on. [widget.png] On Construct you position it in the viewport via an exposed variable and you set a target location for it to move towards to. The fading animating starts playing immediately. Event Tick will update its position. The animation changes text’s opacity from 1 to 0 over 1s and once it’s over, the widget gets removed from the viewport and garbage coll…

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?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 2, 2023, 8:52pm UTC](https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712/2 "2023-01-02T20:52:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 3, 2023, 7:48am UTC](https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712/3 "2023-01-03T07:48:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Krileon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Krileon](https://forums.unrealengine.com/u/Krileon)\
**Post date:** [January 3, 2023, 2:18pm UTC](https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712/4 "2023-01-03T14:18:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 3, 2023, 3:12pm UTC](https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712/5 "2023-01-03T15:12:16Z")

</div>

- 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:

> [@Is it possible to make 3d UMG widgets never get occluded?](https://forums.unrealengine.com/t/is-it-possible-to-make-3d-umg-widgets-never-get-occluded/408536/2):
>
> Yes. find material in the engine content: Widget3DPassThrough duplicate it and move it to your project. open the material and Disable Depth Test in the advanced part of the Translucency tab assign material to your widget component

* * *

> 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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/e/2/3e205002dbe67b057c8f5f47c593c8ca9ff83216.jpeg)

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

---

<div class="post-metadata">

**Author:** ![Krileon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Krileon](https://forums.unrealengine.com/u/Krileon)\
**Post date:** [January 3, 2023, 5:19pm UTC](https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712/6 "2023-01-03T17:19:54Z")

</div>

> [@Everynone](#):
>
> - widget components in Screen Space are z-sorted automatically and _follow_ their actors:

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.

> [@Everynone](#):
>
> Perhaps you could demo the undesired behaviour and produce and example of how you’d like to them to behave?

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.

> [@Everynone](#):
>
> If you did not want to use a widget component, the actor can shift them around with something similar to this pseduoscript:

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

---

<div class="post-metadata">

**Author:** ![Krileon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Krileon](https://forums.unrealengine.com/u/Krileon)\
**Post date:** [January 3, 2023, 6:31pm UTC](https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712/7 "2023-01-03T18:31:38Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/3/b/a3b03a5b0ec4e975d25e24f50ef7120fc8c514f2.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/6/4/2644b9f864febf30ebd12096968faa5ea3c10abb.png)

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

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/2/1320583b1d612d13b3058d7c8af9a405b418a038.png)

Seams to work well enough.

---

<div class="post-metadata">

**Author:** ![Krileon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Krileon](https://forums.unrealengine.com/u/Krileon)\
**Post date:** [January 3, 2023, 6:56pm UTC](https://forums.unrealengine.com/t/how-to-prevent-screen-space-ui-elements-from-moving-with-the-player/740712/8 "2023-01-03T18:56:29Z")

</div>

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

Component

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/5/3/c53d4477c52be07e92d547db418c6823deb1bff8.png)

Widget

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/6/2/a62763d0c5adbc00ec81d32b7be4e19fd04961a5.png)

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