fix movable and menu
This commit is contained in:
parent
5605934e03
commit
0433331e2b
|
@ -9,18 +9,27 @@ signal on_moved()
|
||||||
@export var restrict_movement: Callable
|
@export var restrict_movement: Callable
|
||||||
@export var lock_rotation: bool = false
|
@export var lock_rotation: bool = false
|
||||||
var hit_node := Node3D.new()
|
var hit_node := Node3D.new()
|
||||||
|
var initiator = null
|
||||||
|
|
||||||
func _on_grab_down(event: EventPointer):
|
func _on_grab_down(event: EventPointer):
|
||||||
if restricted&&event.target != get_parent():
|
if restricted&&event.target != get_parent():
|
||||||
return
|
return
|
||||||
|
|
||||||
event.initiator.node.add_child(hit_node)
|
initiator = event.initiator
|
||||||
|
|
||||||
|
if hit_node.get_parent() != null:
|
||||||
|
hit_node.get_parent().remove_child(hit_node)
|
||||||
|
|
||||||
|
initiator.node.add_child(hit_node)
|
||||||
hit_node.global_transform = get_parent().global_transform
|
hit_node.global_transform = get_parent().global_transform
|
||||||
|
|
||||||
func _on_grab_move(_event: EventPointer):
|
func _on_grab_move(event: EventPointer):
|
||||||
if hit_node.get_parent() == null:
|
if hit_node.get_parent() == null:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if event.initiator != initiator:
|
||||||
|
return
|
||||||
|
|
||||||
if restrict_movement:
|
if restrict_movement:
|
||||||
get_parent().global_position = restrict_movement.call(hit_node.global_position)
|
get_parent().global_position = restrict_movement.call(hit_node.global_position)
|
||||||
else:
|
else:
|
||||||
|
@ -33,7 +42,14 @@ func _on_grab_move(_event: EventPointer):
|
||||||
on_move.emit(get_parent().global_position, Vector3(0, 0, 0))
|
on_move.emit(get_parent().global_position, Vector3(0, 0, 0))
|
||||||
|
|
||||||
func _on_grab_up(event: EventPointer):
|
func _on_grab_up(event: EventPointer):
|
||||||
event.initiator.node.remove_child(hit_node)
|
if event.initiator != initiator:
|
||||||
|
return
|
||||||
|
|
||||||
|
if hit_node.get_parent() == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
initiator = null
|
||||||
|
hit_node.get_parent().remove_child(hit_node)
|
||||||
on_moved.emit()
|
on_moved.emit()
|
||||||
|
|
||||||
func _get_configuration_warnings() -> PackedStringArray:
|
func _get_configuration_warnings() -> PackedStringArray:
|
||||||
|
@ -42,5 +58,4 @@ func _get_configuration_warnings() -> PackedStringArray:
|
||||||
if get_parent() is StaticBody3D == false:
|
if get_parent() is StaticBody3D == false:
|
||||||
warnings.append("Movable requires a StaticBody3D as parent.")
|
warnings.append("Movable requires a StaticBody3D as parent.")
|
||||||
|
|
||||||
|
|
||||||
return warnings
|
return warnings
|
||||||
|
|
|
@ -122,12 +122,12 @@ func _process_hand(hand: OpenXRHand):
|
||||||
initiator.on_release.emit(Initiator.EventType.GRIP)
|
initiator.on_release.emit(Initiator.EventType.GRIP)
|
||||||
grabbed_left = false
|
grabbed_left = false
|
||||||
else:
|
else:
|
||||||
if trigger_close&&!grabbed_right:
|
if trigger_close&&!grabbed_left:
|
||||||
initiator.on_press.emit(Initiator.EventType.GRIP)
|
initiator.on_press.emit(Initiator.EventType.GRIP)
|
||||||
grabbed_right = true
|
grabbed_left = true
|
||||||
elif !trigger_close&&grabbed_right:
|
elif !trigger_close&&grabbed_left:
|
||||||
initiator.on_release.emit(Initiator.EventType.GRIP)
|
initiator.on_release.emit(Initiator.EventType.GRIP)
|
||||||
grabbed_right = false
|
grabbed_left = false
|
||||||
else:
|
else:
|
||||||
if !distance_close:
|
if !distance_close:
|
||||||
if trigger_close&&!pressed_right:
|
if trigger_close&&!pressed_right:
|
||||||
|
|
|
@ -45,7 +45,7 @@ outline_size = 0
|
||||||
autowrap_mode = 3
|
autowrap_mode = 3
|
||||||
width = 40.0
|
width = 40.0
|
||||||
|
|
||||||
[node name="FingerArea" type="Area3D" parent="."]
|
[node name="FingerArea" type="Area3D" parent="." groups=["ui_focus_skip"]]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.015)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.015)
|
||||||
collision_layer = 4
|
collision_layer = 4
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
|
|
|
@ -188,8 +188,8 @@ _data = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Menu" type="StaticBody3D"]
|
[node name="Menu" type="StaticBody3D"]
|
||||||
collision_layer = 2
|
collision_layer = 6
|
||||||
collision_mask = 2
|
collision_mask = 6
|
||||||
script = ExtResource("1_ng4u3")
|
script = ExtResource("1_ng4u3")
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
@ -199,14 +199,8 @@ shape = SubResource("BoxShape3D_e1esh")
|
||||||
[node name="Movable" type="Node" parent="."]
|
[node name="Movable" type="Node" parent="."]
|
||||||
script = ExtResource("2_8coxu")
|
script = ExtResource("2_8coxu")
|
||||||
|
|
||||||
[node name="AnimationContainer" type="StaticBody3D" parent="."]
|
[node name="AnimationContainer" type="Node3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, 0.15, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, 0.15, 0)
|
||||||
collision_layer = 6
|
|
||||||
collision_mask = 6
|
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="AnimationContainer"]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.15, -0.005)
|
|
||||||
shape = SubResource("BoxShape3D_e1esh")
|
|
||||||
|
|
||||||
[node name="Background" type="MeshInstance3D" parent="AnimationContainer"]
|
[node name="Background" type="MeshInstance3D" parent="AnimationContainer"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, 0.23, -0.15, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, 0.23, -0.15, 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user