0 votes

I have a script to draw a little cross on the mouse position when I click with the mouse. This position is sent to another script through event handler for more functionality. I override the draw in the first script to draw the mouse position, and did the same to the receiver script. The problem is, the cross is drawn with offset on the receiver script, but the mouse position is the same when I checked with the GD.Print. I'm using GetGlobalMousePosition() , but the problem isn't solved with GetLocalMousePosition().

https://imgshare.io/image/mousepositionbug.p0K7D8
[White is mouse - Red is PlayerController]
https://imgshare.io/image/mousepositionbug2.p0K3xK

Edit 1: After some testing, I discovered that the CanvasItem Transform is the guilty here. Still don't know how to fix, but I can see the problem now.

Godot version Godot Engine v3.3.2.stable.mono.official
in Engine by (16 points)
edited by

1 Answer

0 votes

Using the function GetGlobalTransform().XFormInv(Vector2 position) worked, however, it changed the position of the mouse, but it drew the cross exact on the click, so I don't know anymore what is going on.

by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.