From e8c7cb3e33b6925868765ff930fc861241fc257f Mon Sep 17 00:00:00 2001 From: karl Date: Sat, 1 Feb 2020 13:00:25 +0100 Subject: [PATCH] Players can fight each other (but bose lose health) --- BodyParts/Arm.tscn | 8 +++++--- BodyParts/BodyBase/BodyBase.gd | 6 +++--- BodyParts/BodyBase/BodyBase.tscn | 5 +++-- BodyParts/BodyPart.gd | 4 ++-- BodyParts/PushingBodyPart.gd | 2 +- Ingame/Testing.tscn | 12 ++++++++++++ project.godot | 2 ++ 7 files changed, 28 insertions(+), 11 deletions(-) diff --git a/BodyParts/Arm.tscn b/BodyParts/Arm.tscn index a72ea91..200c275 100644 --- a/BodyParts/Arm.tscn +++ b/BodyParts/Arm.tscn @@ -4,7 +4,9 @@ [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="CapsuleShape" id=3] +radius = 0.724339 +height = 5.27855 [sub_resource type="SphereShape" id=2] radius = 0.591769 @@ -13,8 +15,8 @@ radius = 0.591769 script = ExtResource( 3 ) [node name="PartCollider" parent="." index="0"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -8 ) -shape = SubResource( 1 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5.34203 ) +shape = SubResource( 3 ) [node name="Mesh" parent="." index="1" instance=ExtResource( 2 )] diff --git a/BodyParts/BodyBase/BodyBase.gd b/BodyParts/BodyBase/BodyBase.gd index 99d95e9..f48b502 100644 --- a/BodyParts/BodyBase/BodyBase.gd +++ b/BodyParts/BodyBase/BodyBase.gd @@ -1,9 +1,9 @@ extends Spatial class_name BodyBase -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" + +export(int) var player_id + # Called when the node enters the scene tree for the first time. func _ready(): diff --git a/BodyParts/BodyBase/BodyBase.tscn b/BodyParts/BodyBase/BodyBase.tscn index ee8024b..e52a13e 100644 --- a/BodyParts/BodyBase/BodyBase.tscn +++ b/BodyParts/BodyBase/BodyBase.tscn @@ -12,7 +12,9 @@ [sub_resource type="SphereShape" id=5] -[node name="Torso" type="RigidBody"] +[node name="Torso" type="RigidBody" groups=[ +"Player", +]] script = ExtResource( 1 ) [node name="TorsoMesh" type="MeshInstance" parent="."] @@ -20,7 +22,6 @@ mesh = SubResource( 1 ) material/0 = null [node name="TorsoCollider" type="CollisionShape" parent="."] -transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 ) shape = SubResource( 2 ) [node name="FrontLeft" type="Spatial" parent="."] diff --git a/BodyParts/BodyPart.gd b/BodyParts/BodyPart.gd index 62385c9..18f6034 100644 --- a/BodyParts/BodyPart.gd +++ b/BodyParts/BodyPart.gd @@ -22,13 +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.origin + var translation = physics_shape.global_transform print(translation) remove_child(physics_shape) base.add_child(physics_shape) - physics_shape.global_transform.origin = translation + physics_shape.global_transform = translation setup_done = true diff --git a/BodyParts/PushingBodyPart.gd b/BodyParts/PushingBodyPart.gd index 1ddf25e..11e5615 100644 --- a/BodyParts/PushingBodyPart.gd +++ b/BodyParts/PushingBodyPart.gd @@ -16,7 +16,7 @@ func _on_touch_area_entered(body): if body.is_in_group("Terrain"): push(body) elif body.is_in_group("Player"): - InGameState.subtract_player_health(body.id, damage) + InGameState.subtract_player_health(body.player_id, damage) func push(body): diff --git a/Ingame/Testing.tscn b/Ingame/Testing.tscn index 552dc89..6b3c697 100644 --- a/Ingame/Testing.tscn +++ b/Ingame/Testing.tscn @@ -43,6 +43,18 @@ key = 83 [node name="Arm" parent="Torso/FrontRight" index="1" instance=ExtResource( 1 )] key = 65 +[node name="Torso2" parent="." instance=ExtResource( 3 )] +transform = Transform( -0.866025, -0.353553, -0.353553, -6.18172e-08, -0.707107, 0.707107, -0.5, 0.612372, 0.612372, 0, 3.02111, -9 ) +player_id = 1 + +[node name="Arm" parent="Torso2/FrontLeft" index="1" instance=ExtResource( 1 )] +key = 81 + +[node name="Arm" parent="Torso2/FrontRight" index="1" instance=ExtResource( 1 )] +key = 87 + [node name="UI" parent="." instance=ExtResource( 2 )] [editable path="Torso"] + +[editable path="Torso2"] diff --git a/project.godot b/project.godot index b3782d6..0337e80 100644 --- a/project.godot +++ b/project.godot @@ -33,10 +33,12 @@ _global_script_class_icons={ [application] config/name="BodyPartFighter" +run/main_scene="res://Ingame/Testing.tscn" config/icon="res://icon.png" [autoload] +InGameState="*res://Global/InGameState.gd" BodyPartLoader="*res://Global/BodyPartLoader.gd" [rendering]