• 2D
  • get_mouse_pos not returning mouse position

Hi All,I'm having a crack at making my first game in Godot. It seems like a lovely engine, but I've run in to a problem. I'm trying to build a top down 2d shooter, where the player fires a bullet from their position in the direction of the mouse cursor.I'm using get_mouse_pos to get the mouse position, but it doesn't seem to be giving me the absolute mouse position. Instead, it seems to giving me a varying location in relation to the mouse cursor, which changes in relation to where my character is in the level (this is presumably as the camera tracks the player, so it is looking at a different part of the viewport).I tested this by creating a node which is just an image, and attaching a script to it that runs get_mouse_pos in process.If I move the character over to the left (and the camera scrolls left with him), the reported mouse position drifts in relation to the mouse cursor - i can tell as the image moves.I presume this is something to do with the viewport, but I don't know how to fix it.Is there anything I can do get the absolute position of the mouse cursor? What is the value that get_mouse_pos is actually reporting?Thanks!

I once stumbled upon this, too. IIRC I ended up using CanvasItem.get_local_mouse_pos() or CanvasItem.get_global_mouse_pos()

That worked, thanks!For anyone else trying it, I didn't have to call it from CanvasItem - I just called it from the sprite class I was in (get_global_mouse_pos())