diff --git a/project/objects/player.tscn b/project/objects/player.tscn index 7da776e2..aa535842 100644 --- a/project/objects/player.tscn +++ b/project/objects/player.tscn @@ -1,9 +1,19 @@ -[gd_scene load_steps=3 format=3 uid="uid://snjgu4yp5swd"] +[gd_scene load_steps=5 format=3 uid="uid://snjgu4yp5swd"] [ext_resource type="PackedScene" uid="uid://ce40pq785yoyi" path="res://objects/weapons/rifle.tscn" id="1_eqqp1"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_bxedw"] +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_eqqp1"] +radius = 0.3173828 + +[sub_resource type="GDScript" id="GDScript_eqqp1"] +script/source = "extends HealthStatus + +func _on_health_changed(remaining: int, delta: int) -> void: + print(\"Player Health Changed:\", delta, \"remaining:\", remaining) +" + [node name="PlayerBody" type="PlayerBody"] [node name="CollisionShape3D" type="CollisionShape3D" parent="."] @@ -21,3 +31,18 @@ fov = 60.0 [node name="WeaponInventory" type="WeaponInventory" parent="."] unique_name_in_owner = true starting_weapon = ExtResource("1_eqqp1") + +[node name="Hitbox" type="Hitbox" parent="." node_paths=PackedStringArray("health")] +collision_layer = 8 +collision_mask = 0 +monitoring = false +health = NodePath("../HealthStatus") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +shape = SubResource("CapsuleShape3D_eqqp1") + +[node name="HealthStatus" type="HealthStatus" parent="."] +script = SubResource("GDScript_eqqp1") + +[connection signal="health_changed" from="HealthStatus" to="HealthStatus" method="_on_health_changed"] diff --git a/project/objects/weapons/rifle.tscn b/project/objects/weapons/rifle.tscn index b8334d78..25b94677 100644 --- a/project/objects/weapons/rifle.tscn +++ b/project/objects/weapons/rifle.tscn @@ -22,7 +22,7 @@ bone_idx = 39 unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 0.99999833, -0.0017453281, 0, 0.0017453281, 0.99999833, 1.4540284e-26, 0, 0.027612558) target_position = Vector3(0, 100, 0) -collision_mask = 2 +collision_mask = 6 collide_with_areas = true spread = 0.003 diff --git a/project/project.godot b/project/project.godot index 4575b2d6..8844fdb1 100644 --- a/project/project.godot +++ b/project/project.godot @@ -74,3 +74,5 @@ switch_weapon={ 3d_render/layer_2="FirstPerson" 3d_physics/layer_1="General" 3d_physics/layer_2="Precision" +3d_physics/layer_3="Hitbox(Enemy)" +3d_physics/layer_4="Hitbox(Player)"