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

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?

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. Might also have to do orthographics.render.helper.set_screen_view_projection() and orthographics.render.helper.set_world_view_projection().

1 Like

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?

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

Yep, already done.
01

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?

1 Like

Done, thank you!

1 Like

This has been fixed in 2.8.0:

1 Like

Wow!

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

2 Likes

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:

v2.11.2:

OrthographicWorldToScreen.zip (3.2 KB)

:cry:

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?

Of course, and thanks! https://github.com/britzl/defold-orthographic/issues/39

1 Like

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

The issue was resolved in a new release of Orthographic: https://github.com/britzl/defold-orthographic/releases/tag/2.11.4

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