How to transform mouse position to camera2d viewspace

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

I want to have drag and drop UI, but when I change the camera zoom level, the mouse position becomes unlinked from where the mouse actually is on screen.

I looked up how to do this and got the answer of:

GetViewport().CanvasTransform.AffineInverse().BasisXform(GetViewport().GetMousePosition())

But it doesn’t seem to be doing anything at all.

:bust_in_silhouette: Reply From: TheAppleBoom

I was trying to do a bunch of fancy calls from the resources I was reading from when all I needed was to call GetGlobalMousePosition() and everything just worked. Oops…