No sweat, let me just swoop in like Superman and solve all your problems.
So, do you know the difference between action.x/y and action.screen_x/screen_y?
action.screen_x/screen_y - The ‘actual’ pixel position of your mouse inside the window.
action.x/y - Your mouse position in what I like to call “GUI coordinates”. This is what you get when you take the display width/height from your project settings and stretch them to fit your window.
When you first start a project, the window is the size you set in your project settings (game.project), so both coordinate systems match up. They are the same. But as soon as you resize the window at all, they will be different from each other.
Problem #1 - debug circle
Maybe I should make it more obvious, but if you look at the Readme for the debug-draw library, it says:
NOTE: Unless you mess with your render script, all coordinates are in world space.
So trying to match it up with a GUI node is basically just not going to work. It’s drawing in world space, so if you move the camera at all or resize the window then it won’t match up with gui stuff or screen coordinates. If you want you can try editing the render script to move render.draw_debug3d() after the GUI rendering stuff, that might just work.
Problem #2 - gamepad gui flying away…
If you resize the window just a tiny bit you’ll notice that it doesn’t actually teleport, it moves along over time. So that tells you that it’s not what happens on click press, something’s going wrong continuously, which means it’s either on update or on_input. In your on_input(), you’re only doing stuff on action.pressed or action.released, so that only leaves update().
Not a lot there to go wrong, and only one line where you’re changing the position of the node.
Here’s the problem:
local node = gui.get_node("gamepad_back")
self.gamepad_back_pos = gui.get_screen_position(node)
You’re getting the screen position, but there’s no gui.set_screen_position…you’re using the node’s screen position to set it’s normal gui position, every frame. So it’s zooming off to the point where those two positions are the same.
*SWOOSH, Ross flies away to fight more evil