Attach the sprite to the cursor

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

Do 2d top down game and can not figure out how to attach the sprite to the mouse cursor. In 3D mode I would use raycast to get the cursor position in 3D space, but in 2D it doesn’t work. I tried to use get_viewport().get_mouse_position (), but this does not work correctly. How to do it?

:bust_in_silhouette: Reply From: BorisJohnson

I found a solution. I needed to use- get_global_mouse_position()