Players can fight each other (but bose lose health)

This commit is contained in:
karl 2020-02-01 13:00:25 +01:00
parent c73f181dd5
commit e8c7cb3e33
7 changed files with 28 additions and 11 deletions

View File

@ -4,7 +4,9 @@
[ext_resource path="res://3D Input/untitled.glb" type="PackedScene" id=2] [ext_resource path="res://3D Input/untitled.glb" type="PackedScene" id=2]
[ext_resource path="res://BodyParts/Arm.gd" type="Script" id=3] [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] [sub_resource type="SphereShape" id=2]
radius = 0.591769 radius = 0.591769
@ -13,8 +15,8 @@ radius = 0.591769
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="PartCollider" parent="." index="0"] [node name="PartCollider" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -8 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5.34203 )
shape = SubResource( 1 ) shape = SubResource( 3 )
[node name="Mesh" parent="." index="1" instance=ExtResource( 2 )] [node name="Mesh" parent="." index="1" instance=ExtResource( 2 )]

View File

@ -1,9 +1,9 @@
extends Spatial extends Spatial
class_name BodyBase class_name BodyBase
# Declare member variables here. Examples:
# var a = 2 export(int) var player_id
# var b = "text"
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():

View File

@ -12,7 +12,9 @@
[sub_resource type="SphereShape" id=5] [sub_resource type="SphereShape" id=5]
[node name="Torso" type="RigidBody"] [node name="Torso" type="RigidBody" groups=[
"Player",
]]
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="TorsoMesh" type="MeshInstance" parent="."] [node name="TorsoMesh" type="MeshInstance" parent="."]
@ -20,7 +22,6 @@ mesh = SubResource( 1 )
material/0 = null material/0 = null
[node name="TorsoCollider" type="CollisionShape" parent="."] [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 ) shape = SubResource( 2 )
[node name="FrontLeft" type="Spatial" parent="."] [node name="FrontLeft" type="Spatial" parent="."]

View File

@ -22,13 +22,13 @@ func _ready() -> void:
func _process(delta: float) -> void: func _process(delta: float) -> void:
# We do this here because we want the whole tree to really be done instancing # We do this here because we want the whole tree to really be done instancing
if not setup_done: if not setup_done:
var translation = physics_shape.global_transform.origin var translation = physics_shape.global_transform
print(translation) print(translation)
remove_child(physics_shape) remove_child(physics_shape)
base.add_child(physics_shape) base.add_child(physics_shape)
physics_shape.global_transform.origin = translation physics_shape.global_transform = translation
setup_done = true setup_done = true

View File

@ -16,7 +16,7 @@ func _on_touch_area_entered(body):
if body.is_in_group("Terrain"): if body.is_in_group("Terrain"):
push(body) push(body)
elif body.is_in_group("Player"): elif body.is_in_group("Player"):
InGameState.subtract_player_health(body.id, damage) InGameState.subtract_player_health(body.player_id, damage)
func push(body): func push(body):

View File

@ -43,6 +43,18 @@ key = 83
[node name="Arm" parent="Torso/FrontRight" index="1" instance=ExtResource( 1 )] [node name="Arm" parent="Torso/FrontRight" index="1" instance=ExtResource( 1 )]
key = 65 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 )] [node name="UI" parent="." instance=ExtResource( 2 )]
[editable path="Torso"] [editable path="Torso"]
[editable path="Torso2"]

View File

@ -33,10 +33,12 @@ _global_script_class_icons={
[application] [application]
config/name="BodyPartFighter" config/name="BodyPartFighter"
run/main_scene="res://Ingame/Testing.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[autoload] [autoload]
InGameState="*res://Global/InGameState.gd"
BodyPartLoader="*res://Global/BodyPartLoader.gd" BodyPartLoader="*res://Global/BodyPartLoader.gd"
[rendering] [rendering]