diff --git a/characters/target/assets/playermesh.blend.import b/characters/target/assets/playermesh.blend.import new file mode 100644 index 0000000..ae62ee9 --- /dev/null +++ b/characters/target/assets/playermesh.blend.import @@ -0,0 +1,50 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://ckgate4oq25l5" +path="res://.godot/imported/playermesh.blend-ced1b274adcccb114d1d1a807b1c25c0.scn" + +[deps] + +source_file="res://characters/target/assets/playermesh.blend" +dest_files=["res://.godot/imported/playermesh.blend-ced1b274adcccb114d1d1a807b1c25c0.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +meshes/ensure_tangents=true +meshes/generate_lods=false +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +meshes/force_disable_compression=false +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +import_script/path="" +_subresources={} +gltf/naming_version=1 +gltf/embedded_image_handling=1 +blender/nodes/visible=0 +blender/nodes/punctual_lights=true +blender/nodes/cameras=true +blender/nodes/custom_properties=true +blender/nodes/modifiers=1 +blender/meshes/colors=false +blender/meshes/uvs=true +blender/meshes/normals=true +blender/meshes/tangents=true +blender/meshes/skins=2 +blender/meshes/export_bones_deforming_mesh_only=false +blender/materials/unpack_enabled=true +blender/materials/export_materials=1 +blender/animation/limit_playback=true +blender/animation/always_sample=true +blender/animation/group_tracks=true diff --git a/characters/target/target.gd b/characters/target/target.gd new file mode 100644 index 0000000..8558b6b --- /dev/null +++ b/characters/target/target.gd @@ -0,0 +1,25 @@ +class_name Target +extends RigidBody3D + +@export var respawn_time_seconds := 5.0 + +@onready var health_component: HealthComponent = $HealthComponent +@onready var graphics: Node3D = $Graphics +@onready var collision_shape_3d: CollisionShape3D = $CollisionShape3D + +var start_pos : Vector3 + + +func _ready() -> void: + health_component.health_zeroed.connect(respawn_target) + start_pos = global_position + + +func respawn_target(): + graphics.hide() + collision_shape_3d.disabled = true + await get_tree().create_timer(respawn_time_seconds).timeout + health_component.reset() + global_position = start_pos + graphics.show() + collision_shape_3d.disabled = false diff --git a/characters/target/target.tscn b/characters/target/target.tscn new file mode 100644 index 0000000..20e0665 --- /dev/null +++ b/characters/target/target.tscn @@ -0,0 +1,96 @@ +[gd_scene load_steps=5 format=3 uid="uid://dpnu1lvfncx6q"] + +[ext_resource type="PackedScene" uid="uid://ckgate4oq25l5" path="res://characters/target/assets/playermesh.blend" id="1_0ljam"] +[ext_resource type="Script" path="res://characters/target/target.gd" id="1_opjsn"] +[ext_resource type="PackedScene" uid="uid://bof3mg7wgxrmn" path="res://components/health_component.tscn" id="2_kskm1"] + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_rk1ox"] +radius = 0.3 + +[node name="Target" type="RigidBody3D"] +axis_lock_angular_x = true +axis_lock_angular_y = true +axis_lock_angular_z = true +mass = 75.0 +continuous_cd = true +script = ExtResource("1_opjsn") + +[node name="Graphics" type="Node3D" parent="."] +transform = Transform3D(0.75, 0, 0, 0, 0.75, 0, 0, 0, 0.75, 0, -0.916438, 0) + +[node name="playermesh" parent="Graphics" instance=ExtResource("1_0ljam")] + +[node name="Skeleton3D" parent="Graphics/playermesh/playerrig" index="0"] +bones/0/position = Vector3(0, 0.995864, -0.0552) +bones/0/rotation = Quaternion(0.12582, -1.79059e-15, -1.33409e-23, 0.992053) +bones/0/scale = Vector3(1, 1, 1) +bones/1/rotation = Quaternion(-0.0644764, 5.62483e-23, -9.26994e-23, 0.997919) +bones/4/rotation = Quaternion(0.201738, -3.62729e-15, 4.53412e-16, 0.97944) +bones/6/rotation = Quaternion(-0.605155, -0.345862, -0.356135, 0.622363) +bones/7/rotation = Quaternion(-0.244994, 0.787594, -0.344589, 0.448255) +bones/7/scale = Vector3(1, 1, 1) +bones/8/scale = Vector3(1, 1, 1) +bones/9/rotation = Quaternion(0.126866, -0.0346058, -0.00662176, 0.991294) +bones/9/scale = Vector3(1, 1, 1) +bones/11/rotation = Quaternion(-0.0630718, -0.16283, 0.0971492, 0.979832) +bones/13/rotation = Quaternion(0.0299552, -0.545663, -0.00259936, 0.837465) +bones/13/scale = Vector3(1, 1, 1) +bones/14/rotation = Quaternion(-0.0636278, -0.0624373, 0.0299354, 0.995569) +bones/17/rotation = Quaternion(0.0486079, -0.0407852, 0.014286, 0.997883) +bones/19/rotation = Quaternion(-0.12453, -0.526036, 0.129609, 0.831252) +bones/20/rotation = Quaternion(-0.0225172, -0.0668488, 0.0231689, 0.99724) +bones/20/scale = Vector3(1, 1, 1) +bones/21/rotation = Quaternion(-0.00114936, 0.0252308, -0.0174874, 0.999528) +bones/21/scale = Vector3(1, 1, 1) +bones/23/rotation = Quaternion(0.0104723, -0.0704384, 0.0293146, 0.99703) +bones/23/scale = Vector3(1, 1, 1) +bones/25/rotation = Quaternion(-0.605155, 0.345863, 0.356135, 0.622363) +bones/25/scale = Vector3(1, 1, 1) +bones/26/rotation = Quaternion(0.0407172, -0.246634, 0.858112, 0.448506) +bones/26/scale = Vector3(1, 1, 1) +bones/27/scale = Vector3(1, 1, 1) +bones/28/rotation = Quaternion(-0.217102, 0.0422089, 0.0230507, 0.974963) +bones/28/scale = Vector3(1, 1, 1) +bones/30/rotation = Quaternion(-0.0630717, 0.16283, -0.0971492, 0.979832) +bones/30/scale = Vector3(1, 1, 1) +bones/31/rotation = Quaternion(0.0237032, 0.0123211, -0.0433656, 0.998702) +bones/31/scale = Vector3(1, 1, 1) +bones/32/rotation = Quaternion(0.243143, 0.523041, 0.164477, 0.800161) +bones/32/scale = Vector3(1, 1, 1) +bones/33/rotation = Quaternion(-0.0636278, 0.0624373, -0.0299354, 0.995569) +bones/35/rotation = Quaternion(0.113348, 0.545076, 0.134205, 0.819776) +bones/36/rotation = Quaternion(-0.4266, 0.0977703, 0.332942, 0.835226) +bones/37/rotation = Quaternion(-0.632018, -0.129105, 0.241206, 0.725056) +bones/38/rotation = Quaternion(0.0934222, 0.536709, 0.031309, 0.837995) +bones/39/rotation = Quaternion(-0.479327, 0.030236, 0.338389, 0.809212) +bones/40/rotation = Quaternion(-0.540176, -0.0581251, 0.395197, 0.740709) +bones/40/scale = Vector3(1, 1, 1) +bones/41/rotation = Quaternion(0.0241847, 0.530538, 0.0849425, 0.843048) +bones/41/scale = Vector3(1, 1, 1) +bones/42/rotation = Quaternion(-0.451682, -0.0170104, 0.326969, 0.829931) +bones/43/rotation = Quaternion(-0.512965, -0.0942157, 0.391943, 0.757873) +bones/44/rotation = Quaternion(0.986515, -3.3762e-16, 1.34771e-25, 0.163672) +bones/44/scale = Vector3(1, 1, 0.999997) +bones/45/scale = Vector3(1, 1, 1) +bones/46/rotation = Quaternion(-0.574131, 2.92207e-06, -4.58343e-06, 0.818763) +bones/47/rotation = Quaternion(1.99048e-05, 0.961249, -0.27568, 4.3124e-06) +bones/47/scale = Vector3(1, 1, 1) +bones/48/rotation = Quaternion(0.679706, 0.679706, -0.194936, 0.194936) +bones/49/rotation = Quaternion(0.986515, -3.3762e-16, 1.34771e-25, 0.163672) +bones/49/scale = Vector3(1, 1, 0.999997) +bones/50/scale = Vector3(1, 1, 1) +bones/51/rotation = Quaternion(-0.574131, -2.92207e-06, 4.58343e-06, 0.818763) +bones/52/rotation = Quaternion(-1.99048e-05, 0.961249, -0.27568, -4.3124e-06) +bones/52/scale = Vector3(1, 1, 1) +bones/53/rotation = Quaternion(0.679706, -0.679706, 0.194936, 0.194936) + +[node name="AnimationPlayer" parent="Graphics/playermesh" index="4"] +autoplay = "gunOneHanded" + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("CapsuleShape3D_rk1ox") + +[node name="HealthComponent" parent="." instance=ExtResource("2_kskm1")] +max_health = 300 + +[editable path="Graphics/playermesh"] diff --git a/components/health_component.gd b/components/health_component.gd index f2e2a4b..d6bcade 100644 --- a/components/health_component.gd +++ b/components/health_component.gd @@ -15,6 +15,9 @@ func damage(amount : int): if health <= 0: health_zeroed.emit() +func reset(): + health = max_health + func _on_area_entered(area): if area is AreaDamageComponent: damage(area.damage)