only have physics hands in touch areas
This commit is contained in:
parent
933210bbc9
commit
2f3cce84f9
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=20 format=3 uid="uid://c3kdssrmv84kv"]
|
||||
[gd_scene load_steps=21 format=3 uid="uid://c3kdssrmv84kv"]
|
||||
|
||||
[ext_resource type="Script" path="res://content/ui/menu/menu.gd" id="1_ng4u3"]
|
||||
[ext_resource type="Script" path="res://content/functions/movable.gd" id="2_8coxu"]
|
||||
|
@ -187,6 +187,9 @@ _data = {
|
|||
"hide_menu": SubResource("Animation_lkh72")
|
||||
}
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_emmtq"]
|
||||
size = Vector3(0.503906, 0.355225, 0.148712)
|
||||
|
||||
[node name="Menu" type="StaticBody3D"]
|
||||
collision_layer = 6
|
||||
collision_mask = 6
|
||||
|
@ -293,3 +296,12 @@ mesh = ExtResource("7_f4u4o")
|
|||
libraries = {
|
||||
"": SubResource("AnimationLibrary_s30cd")
|
||||
}
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.0194855)
|
||||
shape = SubResource("BoxShape3D_emmtq")
|
||||
|
|
|
@ -27,10 +27,20 @@ func _ready():
|
|||
func _physics_process(_delta):
|
||||
_move_tip_rigidbody_to_bone(tip_body, tip)
|
||||
|
||||
var last_run_active = false
|
||||
|
||||
func _move_tip_rigidbody_to_bone(tip_rigidbody: RigidBody3D, tip_bone: Node3D):
|
||||
if tip_rigidbody.is_inside_tree() == false:
|
||||
return
|
||||
|
||||
if TouchManager.is_touching() == false:
|
||||
hand_mesh.position = Vector3.ZERO
|
||||
last_run_active = false
|
||||
return
|
||||
|
||||
if last_run_active == false:
|
||||
tip_rigidbody.global_position = tip_bone.global_position
|
||||
|
||||
var move_delta: Vector3 = tip_bone.global_position - tip_rigidbody.global_position
|
||||
|
||||
hand_mesh.global_position = hand.global_position - move_delta
|
||||
|
@ -43,3 +53,5 @@ func _move_tip_rigidbody_to_bone(tip_rigidbody: RigidBody3D, tip_bone: Node3D):
|
|||
var coef_force = 30.0
|
||||
tip_rigidbody.apply_central_force(move_delta * coef_force)
|
||||
tip_rigidbody.global_transform.basis = hand.global_transform.basis
|
||||
|
||||
last_run_active = true
|
||||
|
|
|
@ -8,6 +8,9 @@ var finger_areas: Dictionary
|
|||
|
||||
var areas_entered = {}
|
||||
|
||||
func is_touching() -> bool:
|
||||
return areas_entered.keys().size() > 0
|
||||
|
||||
func add_finger(finger_type: Finger.Type, area: Area3D):
|
||||
finger_areas[finger_type] = area
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user