how to make the node return to its original position?

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

i drag a node to the position of the mouse but I want that when I stop pressing it it returns to the position it had before this action
This code is incomplete, I can make it return to position (0,0) but if the node was in another position before dragging it

if Input.is_action_pressed("left"):
		global_position = get_global_mouse_position()

if Input.is_action_just_released("left"):
		print("return_original_position")
:bust_in_silhouette: Reply From: xCode Soul

Very simple

Just save the current position into variable , before move it

var curr_pos = global_position

if Input.is_action_pressed("left"):
    global_position = get_global_mouse_position()

if Input.is_action_just_released(“left”):
global_position = curr_pos