# Project world location to widget position Issue

**URL:** <https://forums.unrealengine.com/t/project-world-location-to-widget-position-issue/1516443>\
**Category:** UI\
**Tags:** unreal-engine, Widget, question\
**Created:** [December 11, 2023, 6:54am UTC](https://forums.unrealengine.com/t/project-world-location-to-widget-position-issue/1516443 "2023-12-11T06:54:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RHIJZY](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RHIJZY](https://forums.unrealengine.com/u/RHIJZY)\
**Post date:** [December 11, 2023, 6:54am UTC](https://forums.unrealengine.com/t/project-world-location-to-widget-position-issue/1516443/1 "2023-12-11T06:54:57Z")

</div>

I have a problem with the following code. the widget(red square) is supposed to follow the white cube in the world. but it doesn’t follow it in the right position and when I move the camera around it’s like it changes position it wants to follow. also I clamped it so that it stays in the corner but when its supposed to be on the bottom it teleports to the left top corner.

 ![De1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/3/c03e5d1931ef00a6729b5a8b1ffab52c4309469a.png)  
 ![De2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/d/4/ad485d4160b019aaf838fc3000b02ec1b00d772a.png)  
 ![De3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/0/72016b1adcc1f7902ac7983d9e6e86280986c820.png)

---

<div class="post-metadata">

**Author:** ![Arodi007](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arodi007/32/1022275_2.png) [@Arodi007](https://forums.unrealengine.com/u/Arodi007)\
**Post date:** [December 11, 2023, 8:52am UTC](https://forums.unrealengine.com/t/project-world-location-to-widget-position-issue/1516443/2 "2023-12-11T08:52:49Z")

</div>

One possible issue is miss timing.

Some function for widget will run only on the next tick and not current tick.

Like GetDesiredSize:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/6/7764fca129f71ba956141ff83255cbeb268e1e04.png)  
This will run only on the tick to get the actual value.

So it possible you are not getting the correct transformation.

Possible solution

- Use of Force Layout Pass (this is pretty expensive especially in a tick event)
- Change method, like using a cube bp attached with a widget component.

---

<div class="post-metadata">

**Author:** ![RHIJZY](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RHIJZY](https://forums.unrealengine.com/u/RHIJZY)\
**Post date:** [December 11, 2023, 9:31am UTC](https://forums.unrealengine.com/t/project-world-location-to-widget-position-issue/1516443/3 "2023-12-11T09:31:22Z")

</div>

Ok so I moved the code over to the cube bp instead of the widget bp and now the location is correct. thank you for the suggestion.  
but the problem with the clamp is still there. when the widget is on the edges of the screen it works fine except the bottom edge of the screen. when it is on the edge of the bottom it teleports to the top left corner as it resets it’s position to zero. the red square is placed on the top left corner in the bp if that helps.

EDIT: the red square is on the cube in the start but when I look away it goes back to the wrong place. 😢

EDIT2: so I changed the set position in viewport to set render translation and it centers on the object perfectly but the problem now is that when I look away espacially when the object is bellow the camera and outside the view it sets back to zero as I tested in print.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [December 11, 2023, 12:23pm UTC](https://forums.unrealengine.com/t/project-world-location-to-widget-position-issue/1516443/4 "2023-12-11T12:23:49Z")

</div>

im pretty sure set position in viewport is broken, i used it before for damage numbers and an update killed it

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [December 11, 2023, 12:25pm UTC](https://forums.unrealengine.com/t/project-world-location-to-widget-position-issue/1516443/5 "2023-12-11T12:25:31Z")

</div>

> [@set position in viewport widget not working](https://forums.unrealengine.com/t/set-position-in-viewport-widget-not-working/692335/11):
>
> Salut, en attendant moi j’utilise “Set render Translation” pour le repositioner correctement [2e26c6fce044c0659cc59638653417f4]

heres another link

---

<div class="post-metadata">

**Author:** ![Arodi007](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arodi007/32/1022275_2.png) [@Arodi007](https://forums.unrealengine.com/u/Arodi007)\
**Post date:** [December 12, 2023, 1:23pm UTC](https://forums.unrealengine.com/t/project-world-location-to-widget-position-issue/1516443/6 "2023-12-12T13:23:42Z")

</div>

If you add the ForceLayoutPass just before the SetPositionInViewport change anything ?
