Hello guys :) :
I'm learning the warpmouseposition(to: Vector2) method and I don't know why, but I can't make the mouse to warp in the desire position, this is my tree scene:
Node2d (parent) (script)
Area2d
Collisionshape2d
parent script:
extends Node2D
onready var Area2d_n := $Area2d
onready var Collisionshape2d_n:=$Collisionshape2d
onready var position_1:Vector2= $Area2d.global_position
func _on_Defense_Area_mouse_exited() -> void:
print("area_exited")
Input.warp_mouse_position(position_1)
these are the transforms position of the nodes:
Node2d= (0,0)
Area2d =(256,256)
Collisionshape2d= (0,0) relative to his parent Area2d
So my intention is to limit the mouse position. When the mouse leaves the Area2d go back to the center of the Area2d. But it adds a weird offset, and even trying this code:
onready var position_1:Vector2= $Area2d.get_global_transform_with_canvas().origin
Still give me a weird offset that is closest to 0,0 and not in the center of the Area2d center position. Anyone knows why and how to fix it?
Thanks a lot.