How to accurately get the mouse position through a viewport?

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

I know this question has been asked numerous times, but I have been unable to find a clear solution other than that this will be fixed in 4.0.

I have a game that requires I get the local mouse position for an object. This works just fine until I render the scene through a viewport in a viewport container, then the coordinates for get_local_mouse_position and get_global_mouse_position are completely thrown off.

Has anyone had this issue and found a solution?