I want to spawn something on mouse position

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MemokingMH

I have a node that I want to spawn on mouse position and make it follow my mouse. But this node is on a canvas layer which makes it work when camera is on 0, 0 coordinates but it shifts through to center when I move the camera. How can I fix this?

:bust_in_silhouette: Reply From: Michalkap
node.position = get_global_mouse_position() - camera.position

should work