I used gui to make a game map. I used no adjust gui(adjust reference:disabled).
I used function to convert click coords to my game coords.All work perfect if i not changing window size.
But looks like gui is depends on window size; When i use same coords in standart and resized window i get different values.
When i don’t change window size all works perfect.
But if i changed widow size, gui.pick_node not work as i need. If increase width, gui pick area less in width and bigger in height.
For example:
standart window:
x= -42 y = -2 working
x= 42 y = -2 working
scale_window:
x= -42 y = -2 not working
x= -37.5 y = -2 working
x= 42 y = -2 not working
I’m not sure of the details here under the hood in the engine but my guess is that gui.pick_node() will not work if you disable adjust mode. @sven should be able to give a proper answer.
Are you using action.x and action.y, or action.screen_x, action.screen_y? I believe gui.pick_node works with action.x and action.y. Those coordinates stay the same, they’re stretched to fit the window, whereas action.screen_x and action.screen_y are based on the actual screen size of the window.
I use world coords cconverted from screen_x and screen_y. But I make test with constant values, see previous post. And I get different values, for normal window, and stretched window.
Yes, I have no adjust GUI. I don’t need scaling or changing GUI position, for different screen sizes, because i am making a game map, which can be scrolled. In future the map can be zoomed. For different aspect ratio, I only change camera size.
Lets call them “picking coordinates”—what you need for gui.pick_node() and what you get from action.x and action.y from mouse or touch input.
And then “screen coordinates”—actual screen pixel coordinates in your window, what you get from action.screen_x and action.screen_y.
configWin — window x and y as defined in your game.project file
curWin — current window x and y
To convert from screen coordinates to picking coordinates, multiply screen position by configWin/curWin (x and y). And do the opposite to convert from picking coordinates to screen coordinates of course. So if you have a screen position inside the node, multiply it by configWin/curWin before using it in gui.pick_node() and it should still give you a hit after you resize the window, if your gui adjust mode is disabled.
Not sure that I understand you. I successfully converted screen coord to world coords.
I will share my example tomorrow.
The problem is that, when for example I use constant world coord, for pick, I get true or false. And it depends on window size. It is strange.
Yeah, an example would help me see what you’re trying to do.
It’s not a bug that the result of pick_node changes depending on your window size. Pick_node doesn’t exactly use screen coordinates, that is, it uses the screen coordinates you set in your game.project, but stretches them to fit the window if it changes. (see the second paragraph here for -some- explanation) So if your display width and height are set to 1280x1024, but you change the window to 1800x600, gui.pick_node will still expect a coordinate in a system where (1280, 1024) is the top right corner of the screen.
You can try printing action.x and action.y on mouse movement to see what I mean.
I make a simple test. I used different coords for gui.pick_node. The green rectangle is world coords. The blue is world cords multiplied by curWin/configWidth.
Looks like node click zone is scaled for no adjust gui. So i need scaled a world coords for it.
It is strange behaver, because node not changed it size. But click zone becoming smaller.