# Creating a gui node in the same visual position as a game object (SOLVED)

**URL:** <https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299>\
**Category:** Questions\
**Created:** [March 14, 2019, 1:46pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299 "2019-03-14T13:46:13Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 14, 2019, 1:46pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/1 "2019-03-14T13:46:13Z")

</div>

I’m use orthographic camera to do this:

1. Use `camera.world_to_screen(camera_id, world)`to get the screen position
2. Send the position to a gui that clones a node, set\_parent to a node in position 0,0 and then sets the position.

This works great if the window hasn’t been resized. If it’s resized the cloned nodes end up in the wrong place. Any idea why?

---

<div class="post-metadata">

**Author:** ![Jerakin](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/jerakin/32/3997_2.png) [@Jerakin](https://forum.defold.com/u/Jerakin)\
**Post date:** [March 14, 2019, 2:49pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/2 "2019-03-14T14:49:17Z")

</div>

Sounds like the stored `width` and `height` are not updated on window resize.

Never used orthographics but maybe try to run `orthographics.render.helper.update()` when you get the `window_resized` [message](https://www.defold.com/ref/render/#window_resized). Might also have to do `orthographics.render.helper.set_screen_view_projection()` and `orthographics.render.helper.set_world_view_projection()`.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 14, 2019, 8:09pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/3 "2019-03-14T20:09:07Z")

</div>

> [@totebo](#):
>
> If it’s resized the cloned nodes end up in the wrong place. Any idea why?

What if you disable the adjust mode (select root of gui and in properties change Adjust Mode from Per Node to Disabled)?

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 15, 2019, 9:18am UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/4 "2019-03-15T09:18:46Z")

</div>

> [@britzl](#):
>
> What if you disable the adjust mode (select root of gui and in properties change Adjust Mode from Per Node to Disabled)?

Same result I’m afraid. @Jerakin’s suggestion is a bit more long winded, do you think it would do the trick @britzl?

---

<div class="post-metadata">

**Author:** ![Jerakin](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/jerakin/32/3997_2.png) [@Jerakin](https://forum.defold.com/u/Jerakin)\
**Post date:** [March 15, 2019, 9:36am UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/5 "2019-03-15T09:36:40Z")

</div>

I forgot to say, but this is already done if you are using `orthographic.render` from the project.  
If you haven’t already under **bootstrap** change **Render** to `/orthographic/render/orthographic.render`

 ![15](https://forum-defold.b-cdn.net/uploads/default/original/2X/d/d31aea554a14f2eeed3071ec379da000bf3777a6.png)

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 15, 2019, 9:39am UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/6 "2019-03-15T09:39:26Z")

</div>

> [@Jerakin](#):
>
> If you haven’t already under **bootstrap** change **Render** to

Yep, already done.

 ![01](https://forum-defold.b-cdn.net/uploads/default/original/2X/2/255131e1f9db841057cdfd3dd184adaa5b2abdfe.png)

I’m using the camera for many other things like culling and it’s been great. This is the first stumbling block!

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 15, 2019, 12:46pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/7 "2019-03-15T12:46:46Z")

</div>

> [@totebo](#):
>
> I’m using the camera for many other things like culling and it’s been great. This is the first stumbling block!

Can you create a ticket in the repo and I’ll take a look as soon as I can?

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 15, 2019, 1:57pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/8 "2019-03-15T13:57:16Z")

</div>

Done, thank you!

> <https://github.com/britzl/defold-orthographic/issues/23>
>
> Works as intended when window hasn't been resized.
> 
> Discussion: 
> https://foru…m.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object/46299/7

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 28, 2019, 8:00am UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/9 "2019-03-28T08:00:31Z")

</div>

This has been fixed in 2.8.0:

> **[Release Orthographic Camera API 2.8.0 · britzl/defold-orthographic](https://github.com/britzl/defold-orthographic/releases/tag/2.8.0)**
>
> NEW: camera.world\_to\_screen() now takes an optional adjust mode. Useful when positioning gui nodes on world coordinates.
> FIX: camera.project() didn't use current window dimensions

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 28, 2019, 9:50am UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/10 "2019-03-28T09:50:36Z")

</div>

> [@britzl](#):
>
> This has been fixed in 2.8.0

Wow!

After a bit of fiddling with gui.set\_parent, I now have sprites being teleported seamlessly between the go and gui worlds. THANKS!

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 15, 2021, 1:19pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/11 "2021-03-15T13:19:59Z")

</div>

> [@totebo](#):
>
> This has been fixed in 2.8.0

I was scratching my head over why this functionality stopped working in my project with the latest Orthographic camera extension. Then I went back to v2.0.8 and it worked again! When I tested versions since v2.0.8 it seems that v2.11.2 introduced a breaking change.

I made a simple example to illustrate the issue. Every time the mouse is pressed, a gui pie node is placed on top of the moving game object.

v2.11.1:

[https://forum.defold.com/uploads/default/original/3X/7/f/7f661633656dc3ab88bdd2769fc7e1042a143081.mov](https://forum.defold.com/uploads/default/original/3X/7/f/7f661633656dc3ab88bdd2769fc7e1042a143081.mov)

v2.11.2:

[https://forum.defold.com/uploads/default/original/3X/7/e/7e2bb8f128b170aea9f96613c4674a6173e85bd4.mov](https://forum.defold.com/uploads/default/original/3X/7/e/7e2bb8f128b170aea9f96613c4674a6173e85bd4.mov)

[OrthographicWorldToScreen.zip](https://forum.defold.com/uploads/default/original/3X/0/6/063cb732698528304f57736125d1e74e12f30ec3.zip) (3.2 KB)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 15, 2021, 1:44pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/12 "2021-03-15T13:44:36Z")

</div>

> [@totebo](#):
>
> Then I went back to v2.0.8 and it worked again! When I tested versions since v2.0.8 it seems that v2.11.2 introduced a breaking change

😢

Nooo! Screen to World and World to Screen with different GUI adjust modes is a nightmare to get right…

Could you please create an Issue in the repo and I’ll take a look as soon as I can?

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [March 15, 2021, 2:22pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/13 "2021-03-15T14:22:40Z")

</div>

> [@britzl](#):
>
> Could you please create an Issue in the repo and I’ll take a look as soon as I can?

Of course, and thanks! [Breaking change to camera.world\_to\_screen() in v2.11.2. · Issue #39 · britzl/defold-orthographic · GitHub](https://github.com/britzl/defold-orthographic/issues/39)

---

<div class="post-metadata">

**Author:** ![rayraytime](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@rayraytime](https://forum.defold.com/u/rayraytime)\
**Post date:** [March 21, 2021, 11:28am UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/14 "2021-03-21T11:28:29Z")

</div>

Any update on this? I’m having a similar issue.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 21, 2021, 4:08pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/15 "2021-03-21T16:08:32Z")

</div>

The issue was resolved in a new release of Orthographic: [Release Orthographic Camera API 2.11.4 · britzl/defold-orthographic · GitHub](https://github.com/britzl/defold-orthographic/releases/tag/2.11.4)

---

<div class="post-metadata">

**Author:** ![rayraytime](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@rayraytime](https://forum.defold.com/u/rayraytime)\
**Post date:** [March 21, 2021, 4:27pm UTC](https://forum.defold.com/t/creating-a-gui-node-in-the-same-visual-position-as-a-game-object-solved/46299/16 "2021-03-21T16:27:15Z")

</div>

I’m still having problems, but I think it’s related to something I’m doing wrong.
