So the gist of what I'm trying to do is get a game character to choose to teleport by pressing space, and then selecting the destination with the mouse. It's set up so that after you press the spacebar, you have 3 seconds during which you can click on a new location for your character. I'm using a 2d camera that the character drags around, and I want the mouse to end up at exactly the same position on the screen as the character at the end of teleportation.
I've been trying:
to teleport the character and then:
Input.warpmousepos(self.getglobalpos() - getnode("Camera2D").getcamerascreencenter() + Vector2(640, 400))
(--> this is for a 1280 x 800 screen, and the Input.warp_mouse positions the cursor so that the left-top edge of your current screen is (0,0), by the way)
but the mouse cursor doesn't end up on the character. I've tried many variations on this line, but none have been successful, though logically I think it should work. There seems to be a changing pattern to where the cursor ends up, but I can't figure out where the problem is, though I suspect it might be with the camera drag margins. Does anyone have any ideas, or any solutions?
On an additional note, I assume that warping just doesn't work correctly with custom cursors? It seems like the cursor stays in the same place after the warp until you actually move it around, at which point it jumps to the new location. These might have similar root causes, I'm not sure...I wish there was a way around this.