Make sliding door with raycast

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kwat
if Input.is_action_pressed("leftmouse") :
	if ray.is_colliding() :
		if ray.get_collider().is_in_group("door"):
			obj = ray.get_collider()
			distance = ex.global_transform.origin - obj.global_transform.origin
			distance.normalized()
			obj.translation.x = lerp(  obj.translation.x,  obj.translation.x + distance.x, 0.1)

The door i use a staticbody, This work well but when i click door imedietly move i just want grab it first and move along with raycast in x axis , i use ex = meshinstace to visual my raycast just like hand
And maybe another trick to create sliding door with raycast