grab translation works when attached to rotated controller

This commit is contained in:
Crispy 2021-05-20 21:05:54 +02:00
parent 37d982458a
commit 5b55d3ce81
2 changed files with 4 additions and 5 deletions

View file

@ -28,7 +28,7 @@ overlay_scene = ExtResource( 7 )
[node name="OverlayInstance UI demo" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.25 )
target = 3
target = 1
overlay_scene = ExtResource( 5 )
[node name="OverlayInteraction" parent="OverlayInstance UI demo" instance=ExtResource( 8 )]

View file

@ -41,11 +41,10 @@ func _ready() -> void:
func _process(_delta: float) -> void:
_update_cursor()
if is_moving:
# var controller_new = _overlay_area.global_transform.inverse() * _active_controller.global_transform
# var controller_delta = move_grab_offset.inverse() * controller_new
# get_parent().transform = move_start_offset * controller_delta
var oc:Transform=_overlay_area.get_parent().transform # controller that overlay is attached to
var global_target = move_grab_pos + _active_controller.translation
get_parent().translation = global_target - _overlay_area.get_parent().translation
global_target = oc.xform_inv(global_target)
get_parent().translation = global_target# - _overlay_area.get_parent().translation
func begin_move():