diff --git a/BodyParts/Arm.gd b/BodyParts/Arm.gd index f3f6ffe..192eda1 100644 --- a/BodyParts/Arm.gd +++ b/BodyParts/Arm.gd @@ -15,7 +15,7 @@ func action(): func push(body): # TODO: Hardcoded values - maybe try to generalize - base.apply_impulse(transform.basis.xform(Vector3(0.0, 0.0, -3.0)), base.transform.basis.y * 10.0) + base.apply_impulse(transform.basis.xform(Vector3(-3.0, 0.0, 0.0)), base.transform.basis.y * 10.0) # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta: float) -> void: diff --git a/BodyParts/Arm.tscn b/BodyParts/Arm.tscn index eda4bfe..a72ea91 100644 --- a/BodyParts/Arm.tscn +++ b/BodyParts/Arm.tscn @@ -4,7 +4,6 @@ [ext_resource path="res://3D Input/untitled.glb" type="PackedScene" id=2] [ext_resource path="res://BodyParts/Arm.gd" type="Script" id=3] - [sub_resource type="SphereShape" id=1] [sub_resource type="SphereShape" id=2] @@ -19,15 +18,18 @@ shape = SubResource( 1 ) [node name="Mesh" parent="." index="1" instance=ExtResource( 2 )] +[node name="Sphere" parent="Mesh" index="0"] +visible = false + [node name="BoneAttachment" type="BoneAttachment" parent="Mesh/Armature/Skeleton" index="1"] -transform = Transform( 1, -1.98292e-23, -3.18966e-24, 6.71348e-24, -9.49949e-08, 1, -2.07636e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -5.05441 ) +transform = Transform( 1, -1.98247e-23, -2.98292e-24, 6.50669e-24, -9.49949e-08, 1, -2.07684e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -5.05441 ) bone_name = "bone_2" [node name="RemoteTransform" type="RemoteTransform" parent="Mesh/Armature/Skeleton/BoneAttachment" index="0"] remote_path = NodePath("../../../../../TouchArea") [node name="TouchArea" parent="." index="2"] -transform = Transform( 1, -1.98292e-23, -3.18966e-24, 6.71348e-24, -9.49949e-08, 1, -2.07636e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -7.60024 ) +transform = Transform( 1, -1.98247e-23, -2.98292e-24, 6.50669e-24, -9.49949e-08, 1, -2.07684e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -7.60024 ) [node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"] transform = Transform( 1, 2.98291e-24, -1.98247e-23, -2.07684e-23, -9.49949e-08, -1, -6.50669e-24, 1, -9.49949e-08, 2.23781e-16, 0.399765, 0.00782054 ) diff --git a/BodyParts/BodyBase/BodyBase.tscn b/BodyParts/BodyBase/BodyBase.tscn index 130277f..8c4318e 100644 --- a/BodyParts/BodyBase/BodyBase.tscn +++ b/BodyParts/BodyBase/BodyBase.tscn @@ -2,7 +2,6 @@ [ext_resource path="res://BodyParts/BodyBase/BodyBase.gd" type="Script" id=1] - [sub_resource type="CapsuleMesh" id=1] [sub_resource type="CapsuleShape" id=2] @@ -24,7 +23,7 @@ material/0 = null shape = SubResource( 2 ) [node name="FrontLeft" type="Spatial" parent="."] -transform = Transform( 1.62921e-07, -5.30863e-14, -1, -3.25841e-07, -1, 0, -1, 3.25841e-07, -1.62921e-07, 0.6, 0, 1 ) +transform = Transform( 0.5, -1.62921e-07, -0.866025, -3.25841e-07, -1, 0, -0.866025, 2.82187e-07, -0.5, 0.6, 0, 1 ) [node name="FrontLeftAttachMent" type="MeshInstance" parent="FrontLeft"] transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0 ) @@ -38,10 +37,10 @@ transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 ) shape = SubResource( 4 ) [node name="FrontRight" type="Spatial" parent="."] -transform = Transform( 1.62921e-07, -5.30863e-14, 1, -3.25841e-07, -1, 0, 1, -3.25841e-07, -1.62921e-07, -0.6, 0, 1 ) +transform = Transform( 0.5, -1.62921e-07, 0.866025, -3.25841e-07, -1, 0, 0.866025, -2.82187e-07, -0.5, -0.6, 0, 1 ) [node name="FrontRightAttachMent" type="MeshInstance" parent="FrontRight"] -transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0 ) +transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 5.0822e-21, 0.3, 0, 0, 0 ) mesh = SubResource( 3 ) material/0 = null diff --git a/BodyParts/BodyPart.gd b/BodyParts/BodyPart.gd index e3b6e2f..62385c9 100644 --- a/BodyParts/BodyPart.gd +++ b/BodyParts/BodyPart.gd @@ -22,12 +22,13 @@ func _ready() -> void: func _process(delta: float) -> void: # We do this here because we want the whole tree to really be done instancing if not setup_done: - var translation = physics_shape.global_transform.basis * physics_shape.translation + var translation = physics_shape.global_transform.origin + print(translation) remove_child(physics_shape) base.add_child(physics_shape) - physics_shape.translation = translation + physics_shape.global_transform.origin = translation setup_done = true diff --git a/BodyParts/PushingBodyPart.gd b/BodyParts/PushingBodyPart.gd index 5b445ef..1ddf25e 100644 --- a/BodyParts/PushingBodyPart.gd +++ b/BodyParts/PushingBodyPart.gd @@ -3,6 +3,8 @@ class_name PushingBodyPart onready var touch_area = get_node("TouchArea") +export(float) var damage = 10.0 + # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -11,7 +13,10 @@ func _ready() -> void: func _on_touch_area_entered(body): if body.name != base.name: - push(body) + if body.is_in_group("Terrain"): + push(body) + elif body.is_in_group("Player"): + InGameState.subtract_player_health(body.id, damage) func push(body): diff --git a/Ingame/Testing.tscn b/Ingame/Testing.tscn index 6d46412..552dc89 100644 --- a/Ingame/Testing.tscn +++ b/Ingame/Testing.tscn @@ -19,7 +19,9 @@ transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 ) mesh = SubResource( 1 ) material/0 = null -[node name="StaticBody" type="StaticBody" parent="MeshInstance"] +[node name="StaticBody" type="StaticBody" parent="MeshInstance" groups=[ +"Terrain", +]] [node name="CollisionShape" type="CollisionShape" parent="MeshInstance/StaticBody"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )