From 1f6e72fb74ee6b51dc87ff99c1ec7e675726a4b0 Mon Sep 17 00:00:00 2001 From: mathias Date: Sun, 2 Feb 2020 16:23:53 +0100 Subject: [PATCH 1/2] Humanhead added, forces for all heads reduced --- BodyParts/BullHead.gd | 2 +- BodyParts/ChickenHead.gd | 2 +- BodyParts/HumanHead.gd | 31 +++++++++++++++++++++++++++++ BodyParts/HumanHead.tscn | 43 ++++++++++++++++++++++++++++++++++++++++ Global/BodyPartLoader.gd | 1 + 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 BodyParts/HumanHead.gd create mode 100644 BodyParts/HumanHead.tscn diff --git a/BodyParts/BullHead.gd b/BodyParts/BullHead.gd index 26f871c..38fcc4e 100644 --- a/BodyParts/BullHead.gd +++ b/BodyParts/BullHead.gd @@ -26,6 +26,6 @@ func action(): func push(body): # We multiply by 0.1 because we only want it to spin slightly, it should mostly go up var offset = transform.basis.xform(Vector3.ZERO) #transform.basis.xform(touch_area.global_transform.origin - base.global_transform.origin) * 0.5 - var direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 19.0 + var direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 3.0 base.apply_impulse(offset, direction) diff --git a/BodyParts/ChickenHead.gd b/BodyParts/ChickenHead.gd index 26f871c..38fcc4e 100644 --- a/BodyParts/ChickenHead.gd +++ b/BodyParts/ChickenHead.gd @@ -26,6 +26,6 @@ func action(): func push(body): # We multiply by 0.1 because we only want it to spin slightly, it should mostly go up var offset = transform.basis.xform(Vector3.ZERO) #transform.basis.xform(touch_area.global_transform.origin - base.global_transform.origin) * 0.5 - var direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 19.0 + var direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 3.0 base.apply_impulse(offset, direction) diff --git a/BodyParts/HumanHead.gd b/BodyParts/HumanHead.gd new file mode 100644 index 0000000..38fcc4e --- /dev/null +++ b/BodyParts/HumanHead.gd @@ -0,0 +1,31 @@ +extends PushingBodyPart + + +onready var anim = get_node("Mesh/AnimationPlayer") + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +func _is_animation_playing(): + return anim.is_playing() + + +func action(): + anim.play("ArmatureAction") + + # Apply a slight counter force + var offset = transform.basis.xform(Vector3.ZERO) #transform.basis.xform(touch_area.global_transform.origin - base.global_transform.origin) * 0.5 + var direction = -(base.transform.basis.y - base.transform.basis.z).normalized() * 0.5 + + base.apply_impulse(offset, direction) + + +func push(body): + # We multiply by 0.1 because we only want it to spin slightly, it should mostly go up + var offset = transform.basis.xform(Vector3.ZERO) #transform.basis.xform(touch_area.global_transform.origin - base.global_transform.origin) * 0.5 + var direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 3.0 + + base.apply_impulse(offset, direction) diff --git a/BodyParts/HumanHead.tscn b/BodyParts/HumanHead.tscn new file mode 100644 index 0000000..883dd9f --- /dev/null +++ b/BodyParts/HumanHead.tscn @@ -0,0 +1,43 @@ +[gd_scene load_steps=7 format=2] + +[ext_resource path="res://BodyParts/PushingBodyPart.tscn" type="PackedScene" id=1] +[ext_resource path="res://3D Input/Fertige GLBs/Kopf_Mensch.glb" type="PackedScene" id=2] +[ext_resource path="res://BodyParts/HumanHead.gd" type="Script" id=3] + +[sub_resource type="SphereShape" id=3] +radius = 0.600362 + +[sub_resource type="SphereShape" id=1] +radius = 2.74607 + +[sub_resource type="SpatialMaterial" id=2] + +[node name="HumanHead" instance=ExtResource( 1 )] +transform = Transform( -3, -9.77524e-07, -4.88762e-07, 4.88762e-07, 7.96295e-14, -3, 9.77524e-07, -3, 7.96295e-14, 0, 0, -1.72516 ) +script = ExtResource( 3 ) + +[node name="PartCollider" parent="." index="0"] +shape = SubResource( 3 ) + +[node name="TouchArea" parent="." index="1"] +transform = Transform( -0.154405, -9.91207e-13, -6.12322e-07, 2.97588e-07, -0.134944, -0.0750402, -5.35145e-07, -0.0750403, 0.134944, 0, 0.372964, 0.00349771 ) + +[node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"] +shape = SubResource( 1 ) + +[node name="Mesh" parent="." index="4" instance=ExtResource( 2 )] + +[node name="Skeleton" parent="Mesh/Armature" index="0"] +bones/2/bound_children = [ NodePath("BoneAttachment") ] + +[node name="HAARE" parent="Mesh/Armature/Skeleton" index="0"] +material/0 = SubResource( 2 ) + +[node name="BoneAttachment" type="BoneAttachment" parent="Mesh/Armature/Skeleton" index="3"] +transform = Transform( -1, -6.36646e-12, -3.96569e-06, 1.92732e-06, -0.87396, -0.485997, -3.46586e-06, -0.485997, 0.87396, -5.43763e-14, 5.658, 0.029508 ) +bone_name = "bone_2" + +[node name="RemoteTransform" type="RemoteTransform" parent="Mesh/Armature/Skeleton/BoneAttachment" index="0"] +remote_path = NodePath("../../../../../TouchArea") + +[editable path="Mesh"] diff --git a/Global/BodyPartLoader.gd b/Global/BodyPartLoader.gd index f6a1098..fcf112d 100644 --- a/Global/BodyPartLoader.gd +++ b/Global/BodyPartLoader.gd @@ -12,3 +12,4 @@ func _ready(): bodyparts["Chicken Head"] = load("res://BodyParts/ChickenHead.tscn") bodyparts["Wings"] = load("res://BodyParts/Wings.tscn") bodyparts["Bull Head"] = load("res://BodyParts/BullHead.tscn") + bodyparts["Human head"] = load("res://BodyParts/HumanHead.tscn") From b8cbe8a0121646f1110937ebdd79a78909ca4a69 Mon Sep 17 00:00:00 2001 From: Ententerminator Date: Sun, 2 Feb 2020 16:31:45 +0100 Subject: [PATCH 2/2] human head cost --- BodyParts/HumanHead.tscn | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/BodyParts/HumanHead.tscn b/BodyParts/HumanHead.tscn index 883dd9f..c34b4c9 100644 --- a/BodyParts/HumanHead.tscn +++ b/BodyParts/HumanHead.tscn @@ -4,26 +4,28 @@ [ext_resource path="res://3D Input/Fertige GLBs/Kopf_Mensch.glb" type="PackedScene" id=2] [ext_resource path="res://BodyParts/HumanHead.gd" type="Script" id=3] -[sub_resource type="SphereShape" id=3] +[sub_resource type="SphereShape" id=1] radius = 0.600362 -[sub_resource type="SphereShape" id=1] +[sub_resource type="SphereShape" id=2] radius = 2.74607 -[sub_resource type="SpatialMaterial" id=2] +[sub_resource type="SpatialMaterial" id=3] [node name="HumanHead" instance=ExtResource( 1 )] transform = Transform( -3, -9.77524e-07, -4.88762e-07, 4.88762e-07, 7.96295e-14, -3, 9.77524e-07, -3, 7.96295e-14, 0, 0, -1.72516 ) script = ExtResource( 3 ) +cost = 10.0 +damage = 5.0 [node name="PartCollider" parent="." index="0"] -shape = SubResource( 3 ) +shape = SubResource( 1 ) [node name="TouchArea" parent="." index="1"] -transform = Transform( -0.154405, -9.91207e-13, -6.12322e-07, 2.97588e-07, -0.134944, -0.0750402, -5.35145e-07, -0.0750403, 0.134944, 0, 0.372964, 0.00349771 ) +transform = Transform( -0.154405, -9.84102e-13, -6.12322e-07, 2.97588e-07, -0.134944, -0.0750402, -5.35145e-07, -0.0750403, 0.134944, 2.84217e-14, 0.372963, 0.00349771 ) [node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"] -shape = SubResource( 1 ) +shape = SubResource( 2 ) [node name="Mesh" parent="." index="4" instance=ExtResource( 2 )] @@ -31,7 +33,7 @@ shape = SubResource( 1 ) bones/2/bound_children = [ NodePath("BoneAttachment") ] [node name="HAARE" parent="Mesh/Armature/Skeleton" index="0"] -material/0 = SubResource( 2 ) +material/0 = SubResource( 3 ) [node name="BoneAttachment" type="BoneAttachment" parent="Mesh/Armature/Skeleton" index="3"] transform = Transform( -1, -6.36646e-12, -3.96569e-06, 1.92732e-06, -0.87396, -0.485997, -3.46586e-06, -0.485997, 0.87396, -5.43763e-14, 5.658, 0.029508 )