diff --git a/Game.gd b/Game.gd index 78897dd..c6595a2 100644 --- a/Game.gd +++ b/Game.gd @@ -122,6 +122,9 @@ sync func remove_player(id): if player.name == str(id): $Players.remove_child(player) +func get_spawn_point(): + return $Level/SpawnPoint + func on_peer_connected(id): print("Peer connected with id ", id) diff --git a/Level.tscn b/Level.tscn index bca1c51..8c9f83f 100644 --- a/Level.tscn +++ b/Level.tscn @@ -1,4 +1,7 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://LevelComponents/Killfloor.tscn" type="PackedScene" id=1] +[ext_resource path="res://LevelComponents/SpawnPoint.tscn" type="PackedScene" id=2] [sub_resource type="BoxShape" id=1] @@ -93,3 +96,8 @@ transform = Transform( 1.3411e-07, -2.98023e-08, -1, 0.258819, 0.965926, 0, 0.96 width = 19.8983 height = 1.04801 depth = 3.06491 + +[node name="Killfloor" parent="." instance=ExtResource( 1 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.3435, 0 ) + +[node name="SpawnPoint" parent="." instance=ExtResource( 2 )] diff --git a/Player.gd b/Player.gd index fe1ea15..bf2eeea 100644 --- a/Player.gd +++ b/Player.gd @@ -26,7 +26,6 @@ var velocity = Vector3.ZERO var walkDirection = Vector2.ZERO var walkDirInt = Vector2.ZERO - # Declare member variables here. Examples: # var a = 2 # var b = "text" @@ -91,6 +90,14 @@ master func on_hit(): health -= 30 print(health) +master func kill(): + health = 0 + spawn() + +func spawn(): + health = 150 + game.get_spawn_point().spawn(self) + func shoot(): var space_state = get_world().direct_space_state diff --git a/Player.tscn b/Player.tscn index e4b4ba6..cb46ad6 100644 --- a/Player.tscn +++ b/Player.tscn @@ -6,11 +6,11 @@ radius = 0.33 height = 1.1 -[sub_resource type="CylinderShape" id=3] +[sub_resource type="CylinderShape" id=2] radius = 0.2 height = 0.3 -[sub_resource type="CapsuleMesh" id=2] +[sub_resource type="CapsuleMesh" id=3] radius = 0.33 mid_height = 1.1 @@ -26,11 +26,11 @@ shape = SubResource( 1 ) [node name="CollisionShapeFeet" type="CollisionShape" parent="."] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.150321, 0 ) -shape = SubResource( 3 ) +shape = SubResource( 2 ) [node name="MeshInstance" type="MeshInstance" parent="."] transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.882822, 0 ) -mesh = SubResource( 2 ) +mesh = SubResource( 3 ) material/0 = null [node name="Debug" type="Label" parent="."]