0 votes

Hey guys im pretty new to godot, and Im having this weird problem where if the node isnt on 0,0 then its creating an offset, ill have a video linked below showing what im talking about, do you have any ideas on how to fix it? Thanks!


in Engine by (20 points)

It probably has something to do with local positions (relative to parent) and global positions.

do you have any ideas on how to fix it? all of the nodes are linked and they're getting the global position of the mouse

I guess you could try using the to_local method to change the coordinates.

no dice yet :/ ill keep trying though, i might just have to start at 0,0 then move it in code to the location i want

I'm not really sure how moving it in code would help, since the end result would still be that the node's coordinates are different than global coordinates.

Would you mind providing a code snippet describing the general idea of how you add the lines? I think the issue may lie in there.

1 Answer

0 votes

You may be using a function that takes relative position instead of global / location position.

Without the actual code you're using, I'll try to answer the best I can.

Subtract the position you've recieved from input from the position of the object you're trying to move. That will give you a relative position using the object as the origin instead of the global origin.

EDIT: After a lot more googling, try using get_global_mouse_position() for mouse click position.

by (14 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.