From 996cb7b6fd2be2be7e1da4feec58a2b4951a91c5 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 12 Feb 2024 09:53:15 +0100 Subject: [PATCH] Added soul collection --- client/item/soul/Soul.gd | 43 ++++++++++++ client/item/soul/Soul.tscn | 114 ++++++++++++++++++++++++------- client/item/soul/color_ramp.tres | 7 ++ client/particle/FadeOut.tres | 8 +++ client/player/Player.tscn | 61 ++--------------- 5 files changed, 155 insertions(+), 78 deletions(-) create mode 100644 client/item/soul/Soul.gd create mode 100644 client/item/soul/color_ramp.tres create mode 100644 client/particle/FadeOut.tres diff --git a/client/item/soul/Soul.gd b/client/item/soul/Soul.gd new file mode 100644 index 0000000..6d96c2d --- /dev/null +++ b/client/item/soul/Soul.gd @@ -0,0 +1,43 @@ +extends Node3D + +var particles: GPUParticles3D +var trails: GPUParticles3D +var attractor: GPUParticlesAttractor3D +var light: Light3D +var sprite: Sprite3D +var area: Area3D + +var collected_by: Player + +func _ready(): + particles = %Particles + trails = %Trail + light = %Light + sprite = %Sprite + area = %Area + attractor = %Attractor + +func _process(delta): + if !collected_by: + return + + position = lerp(position, Global.player.position + Vector3.UP, 1.0 * delta) + +func on_body_entered(body: Node3D): + if body is Player: + collected_by = body + attractor.visible = false + area.set_deferred("monitoring", false) + particles.process_material.attractor_interaction_enabled = true + var duration := 0.5 + + var tween = get_tree().create_tween() + tween.parallel().tween_property(particles, "amount_ratio", 0, duration) + # tween.parallel().tween_property(trails, "amount_ratio", 0, duration) + tween.parallel().tween_property(light, "light_energy", 0, duration) + tween.parallel().tween_property(sprite, "scale", Vector3.ZERO, duration) + tween.parallel().tween_property(sprite, "material_override:albedo_color", Color(0, 0, 0, 0), duration) + await tween.finished + await get_tree().create_timer(2.0).timeout + queue_free() + # tween.tween_callback(queue_free) diff --git a/client/item/soul/Soul.tscn b/client/item/soul/Soul.tscn index 422ffdd..b8708cc 100644 --- a/client/item/soul/Soul.tscn +++ b/client/item/soul/Soul.tscn @@ -1,33 +1,32 @@ -[gd_scene load_steps=7 format=3 uid="uid://dl4vcp04t8iyr"] +[gd_scene load_steps=13 format=3 uid="uid://dl4vcp04t8iyr"] +[ext_resource type="Texture2D" uid="uid://cdoxs0s8xh1b3" path="res://particle/FadeOut.tres" id="1_dd0n2"] [ext_resource type="Texture2D" uid="uid://c3wx3cgn8x62m" path="res://assets/particles/particles-single.png" id="1_hhudy"] - -[sub_resource type="Curve" id="Curve_dga57"] -_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), -1.66657, 0.0, 0, 0] -point_count = 2 - -[sub_resource type="CurveTexture" id="CurveTexture_mxji2"] -curve = SubResource("Curve_dga57") +[ext_resource type="Script" path="res://item/soul/Soul.gd" id="1_mm7cb"] +[ext_resource type="Texture2D" uid="uid://cfkwtmj6tc3wa" path="res://item/soul/color_ramp.tres" id="3_ibw0j"] [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_uyeuh"] -emission_shape = 1 -emission_sphere_radius = 0.25 +lifetime_randomness = 0.15 +spread = 180.0 +initial_velocity_min = 0.1 +initial_velocity_max = 1.0 gravity = Vector3(0, 0, 0) -radial_accel_min = -0.5 -radial_accel_max = -0.25 -tangential_accel_min = 0.25 -tangential_accel_max = 0.5 +tangential_accel_min = -3.0 +tangential_accel_max = 3.0 scale_min = 0.1 -scale_max = 0.2 -color = Color(1, 0.713726, 0.862745, 1) -alpha_curve = SubResource("CurveTexture_mxji2") +scale_max = 0.5 +color_ramp = ExtResource("3_ibw0j") +alpha_curve = ExtResource("1_dd0n2") +hue_variation_min = -0.03 +hue_variation_max = 0.03 +turbulence_noise_speed = Vector3(0.5, 0.5, 0.5) +sub_emitter_mode = 1 +sub_emitter_frequency = 50.0 [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gl2xl"] transparency = 1 blend_mode = 1 cull_mode = 2 -shading_mode = 0 -specular_mode = 2 vertex_color_use_as_albedo = true albedo_texture = ExtResource("1_hhudy") disable_receive_shadows = true @@ -36,13 +35,82 @@ disable_receive_shadows = true material = SubResource("StandardMaterial3D_gl2xl") size = Vector2(0.1, 0.1) -[node name="Soul" type="Node3D"] +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_l1npq"] +lifetime_randomness = 0.05 +gravity = Vector3(0, 0, 0) +attractor_interaction_enabled = false +scale_min = 0.4 +scale_max = 0.4 +scale_curve = ExtResource("1_dd0n2") +color_ramp = ExtResource("3_ibw0j") +alpha_curve = ExtResource("1_dd0n2") -[node name="GPUParticles3D" type="GPUParticles3D" parent="."] +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pk2ln"] +transparency = 1 +blend_mode = 1 +cull_mode = 2 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("1_hhudy") + +[sub_resource type="QuadMesh" id="QuadMesh_pthhm"] +material = SubResource("StandardMaterial3D_pk2ln") +size = Vector2(0.1, 0.1) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ociyh"] +resource_local_to_scene = true +transparency = 1 +blend_mode = 1 +albedo_color = Color(0, 0.501961, 3, 1) +albedo_texture = ExtResource("1_hhudy") +billboard_mode = 1 +billboard_keep_scale = true + +[sub_resource type="SphereShape3D" id="SphereShape3D_rytrf"] +radius = 1.5 + +[node name="Soul" type="Node3D"] +script = ExtResource("1_mm7cb") + +[node name="Particles" type="GPUParticles3D" parent="."] +unique_name_in_owner = true cast_shadow = 0 -amount = 2000 +amount = 50 +sub_emitter = NodePath("../Trail") lifetime = 0.5 transform_align = 1 -trail_lifetime = 0.5 process_material = SubResource("ParticleProcessMaterial_uyeuh") draw_pass_1 = SubResource("QuadMesh_6nr8a") + +[node name="Trail" type="GPUParticles3D" parent="."] +unique_name_in_owner = true +amount = 2500 +lifetime = 0.5 +transform_align = 1 +process_material = SubResource("ParticleProcessMaterial_l1npq") +draw_pass_1 = SubResource("QuadMesh_pthhm") + +[node name="Attractor" type="GPUParticlesAttractorSphere3D" parent="."] +unique_name_in_owner = true +strength = 2.0 +radius = 0.5 + +[node name="Light" type="OmniLight3D" parent="."] +unique_name_in_owner = true +omni_range = 0.5 + +[node name="Sprite" type="Sprite3D" parent="."] +unique_name_in_owner = true +transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0) +material_override = SubResource("StandardMaterial3D_ociyh") +billboard = 1 +double_sided = false +texture = ExtResource("1_hhudy") + +[node name="Area" type="Area3D" parent="."] +unique_name_in_owner = true +monitorable = false + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Area"] +shape = SubResource("SphereShape3D_rytrf") + +[connection signal="body_entered" from="Area" to="." method="on_body_entered"] diff --git a/client/item/soul/color_ramp.tres b/client/item/soul/color_ramp.tres new file mode 100644 index 0000000..e4ba726 --- /dev/null +++ b/client/item/soul/color_ramp.tres @@ -0,0 +1,7 @@ +[gd_resource type="GradientTexture1D" load_steps=2 format=3 uid="uid://cfkwtmj6tc3wa"] + +[sub_resource type="Gradient" id="Gradient_j8niy"] +colors = PackedColorArray(0.05, 0.5, 3, 1, 0, 0, 0, 1) + +[resource] +gradient = SubResource("Gradient_j8niy") diff --git a/client/particle/FadeOut.tres b/client/particle/FadeOut.tres new file mode 100644 index 0000000..887db6a --- /dev/null +++ b/client/particle/FadeOut.tres @@ -0,0 +1,8 @@ +[gd_resource type="CurveTexture" load_steps=2 format=3 uid="uid://cdoxs0s8xh1b3"] + +[sub_resource type="Curve" id="Curve_dfkmm"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 2 + +[resource] +curve = SubResource("Curve_dfkmm") diff --git a/client/player/Player.tscn b/client/player/Player.tscn index 2738431..054e76c 100644 --- a/client/player/Player.tscn +++ b/client/player/Player.tscn @@ -26,65 +26,11 @@ script = ExtResource("1_8gebs") [node name="Armature" parent="Model/Female" index="0"] transform = Transform3D(0.999999, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.000305099, -0.000408816) -[node name="GeneralSkeleton" parent="Model/Female/Armature" index="0"] -bones/1/rotation = Quaternion(1.10655e-09, -2.59221e-24, -2.34947e-16, 1) -bones/2/rotation = Quaternion(-2.64698e-23, 0, 0, 1) -bones/3/rotation = Quaternion(-7.45058e-09, -8.53484e-16, -4.44089e-16, 1) -bones/4/rotation = Quaternion(7.45058e-09, -2.08167e-17, -3.33067e-16, 1) -bones/11/rotation = Quaternion(2.98023e-08, -3.33067e-16, -1.77636e-15, 1) -bones/12/rotation = Quaternion(3.72529e-09, 3.59435e-15, -4.44089e-16, 1) -bones/13/rotation = Quaternion(0.707107, -1.35146e-08, -1.15217e-08, 0.707107) -bones/14/rotation = Quaternion(0.707107, -3.46447e-08, -1.09908e-09, 0.707107) -bones/16/rotation = Quaternion(-2.98023e-08, 1, -2.98023e-08, -2.98023e-08) -bones/17/rotation = Quaternion(2.10734e-08, -0.707107, 0, 0.707107) -bones/18/rotation = Quaternion(0.0288902, 0.701957, -0.0496415, 0.7099) -bones/19/rotation = Quaternion(-0.0554471, 0.00107706, 0.0246517, 0.998157) -bones/20/rotation = Quaternion(-0.0144301, 0.000280172, 0.00955668, 0.99985) -bones/21/rotation = Quaternion(-0.0029327, 0.000187874, -0.00258715, 0.999992) -bones/22/rotation = Quaternion(-0.055445, -3.27826e-07, 0.0149855, 0.998349) -bones/23/rotation = Quaternion(-1.49012e-08, 0, -2.98023e-08, 1) -bones/24/rotation = Quaternion(0.00776948, -4.76837e-07, -0.00960994, 0.999924) -bones/25/rotation = Quaternion(-0.0554483, -2.08616e-07, 0.0149855, 0.998349) -bones/26/rotation = Quaternion(0, 1.49012e-08, 0, 1) -bones/27/rotation = Quaternion(2.98023e-08, 2.98023e-08, 2.98023e-08, 1) -bones/28/rotation = Quaternion(-0.0554469, -2.98023e-07, 0.0149854, 0.998349) -bones/29/rotation = Quaternion(1.49012e-08, 2.98023e-08, 0, 1) -bones/30/rotation = Quaternion(-0.00621979, 1.93715e-07, 0.0114379, 0.999915) -bones/31/rotation = Quaternion(-0.0459777, 0.728478, 0.25833, 0.632828) -bones/32/rotation = Quaternion(-0.0219009, -0.00048776, 0.00526157, 0.999746) -bones/33/rotation = Quaternion(0.0390275, 0.000722662, -0.0124225, 0.999161) -bones/35/rotation = Quaternion(0, 1, 0, -5.96046e-08) -bones/36/rotation = Quaternion(0, 0.707107, 4.21468e-08, 0.707107) -bones/37/rotation = Quaternion(0.0288902, -0.701957, 0.0496415, 0.7099) -bones/38/rotation = Quaternion(-0.055447, -0.00107703, -0.0246517, 0.998157) -bones/39/rotation = Quaternion(-0.01443, -0.000280231, -0.0095567, 0.99985) -bones/40/rotation = Quaternion(-0.00293274, -0.000187755, 0.00258715, 0.999992) -bones/41/rotation = Quaternion(-0.055445, 2.98023e-07, -0.0149855, 0.998349) -bones/42/rotation = Quaternion(-4.47035e-08, 4.47035e-08, -1.49012e-08, 1) -bones/43/rotation = Quaternion(0.00776939, 5.0664e-07, 0.00960997, 0.999924) -bones/44/rotation = Quaternion(-0.0554483, 1.49012e-07, -0.0149856, 0.998349) -bones/45/rotation = Quaternion(1.49012e-08, -1.49012e-08, 1.49012e-08, 1) -bones/46/rotation = Quaternion(0, -1.49012e-08, -1.49012e-08, 1) -bones/47/rotation = Quaternion(-0.0554468, 2.38419e-07, -0.0149854, 0.998349) -bones/48/rotation = Quaternion(0, -1.49012e-08, 0, 1) -bones/49/rotation = Quaternion(-0.0062138, -4.61936e-07, -0.011438, 0.999915) -bones/50/rotation = Quaternion(-0.0459777, -0.728478, -0.25833, 0.632828) -bones/51/rotation = Quaternion(-0.0219009, 0.000487968, -0.00526172, 0.999746) -bones/52/rotation = Quaternion(0.0390272, -0.000721872, 0.0124239, 0.999161) -bones/53/rotation = Quaternion(1.78359e-07, 0.00610319, 0.999981, 7.87824e-09) -bones/54/rotation = Quaternion(-1.15267e-08, 1, -0.000802423, -2.059e-07) -bones/55/rotation = Quaternion(-1.81421e-07, 0.710845, -0.703349, 2.42514e-07) -bones/56/rotation = Quaternion(4.97719e-14, 1, 0, 1.92336e-13) -bones/57/rotation = Quaternion(1.22635e-07, 0.00610348, 0.999981, 4.94272e-08) -bones/58/rotation = Quaternion(-5.5979e-08, 1, -0.000803839, -1.20528e-07) -bones/59/rotation = Quaternion(-1.8142e-07, 0.710844, -0.70335, 2.42513e-07) -bones/60/rotation = Quaternion(-1.28748e-14, 1, 0, 1.16815e-13) - [node name="Chest" parent="Model/Female/Armature/GeneralSkeleton" index="1"] visible = false [node name="BoneAttachment3D" type="BoneAttachment3D" parent="Model/Female/Armature/GeneralSkeleton" index="2"] -transform = Transform3D(1, 6.4651e-15, 4.77396e-15, -6.4651e-15, 1, -6.92683e-08, -4.77396e-15, 6.92683e-08, 1, 1.57651e-10, 1.37156, -0.0247111) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.57651e-10, 1.37156, -0.0247111) bone_name = "Head" bone_idx = 12 @@ -113,6 +59,11 @@ font = ExtResource("4_76ehj") font_size = 256 outline_size = 32 +[node name="Attractor" type="GPUParticlesAttractorSphere3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +strength = 15.0 +radius = 2.0 + [node name="Health" parent="." instance=ExtResource("2_np5ag")] [node name="Movement" parent="." instance=ExtResource("8_25qd0")]