From 06d586d8f0d225ee0fb67f19e610448491332028 Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Thu, 2 Jan 2025 15:16:49 -0700 Subject: [PATCH] Water splash effect --- asset_credits.org | 16 ++ .../audio/436473__rabban625__objectdunk1.mp3 | 3 + asset_dev/particles/bubble.png | 3 + asset_dev/particles/bubble.xcf | Bin 0 -> 1227 bytes assets/sound/sfx/ball/splash1.wav | 3 + assets/sound/sfx/ball/splash1.wav.import | 24 ++ assets/sprites/particles/bubble.png | 3 + assets/sprites/particles/bubble.png.import | 36 +++ assets/sprites/particles/light_03.png | 3 + assets/sprites/particles/light_03.png.import | 34 +++ project.godot | 1 + src/equipment/balls/beach_ball/beach_ball.gd | 5 + .../physics_ball/ball_particle_effects.gd | 8 + src/equipment/balls/physics_ball/ball_sfx.gd | 5 + src/equipment/balls/physics_ball/game_ball.gd | 2 + .../balls/physics_ball/physics_ball.tscn | 16 +- src/world/effects/splash/splash_effect.tscn | 265 ++++++++++++++++++ 17 files changed, 426 insertions(+), 1 deletion(-) create mode 100644 asset_dev/audio/436473__rabban625__objectdunk1.mp3 create mode 100644 asset_dev/particles/bubble.png create mode 100644 asset_dev/particles/bubble.xcf create mode 100644 assets/sound/sfx/ball/splash1.wav create mode 100644 assets/sound/sfx/ball/splash1.wav.import create mode 100644 assets/sprites/particles/bubble.png create mode 100644 assets/sprites/particles/bubble.png.import create mode 100644 assets/sprites/particles/light_03.png create mode 100644 assets/sprites/particles/light_03.png.import create mode 100644 src/world/effects/splash/splash_effect.tscn diff --git a/asset_credits.org b/asset_credits.org index cf51523..553b2a1 100644 --- a/asset_credits.org +++ b/asset_credits.org @@ -11,6 +11,14 @@ Asset credits *** License: CC BY 4.0 +** Kenney.nl particle pack + +*** Retrieved from https://www.kenney.nl/assets/particle-pack + +*** Author: kenney.nl + +*** License: CC0 + * Fonts ** PromptFont @@ -166,3 +174,11 @@ Asset credits *** Author: LiamG_SFX *** License: CC BY 4.0 + +** objectDunk1.MP3 + +*** Retrieved from https://freesound.org/people/rabban625/sounds/436473/ + +*** Author: rabban625 + +*** License: CC0 diff --git a/asset_dev/audio/436473__rabban625__objectdunk1.mp3 b/asset_dev/audio/436473__rabban625__objectdunk1.mp3 new file mode 100644 index 0000000..b0bd28f --- /dev/null +++ b/asset_dev/audio/436473__rabban625__objectdunk1.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:393fc746b71ad2fa00b77f7de77f92ab248faf62fa22159a532d5683c02fe695 +size 165930 diff --git a/asset_dev/particles/bubble.png b/asset_dev/particles/bubble.png new file mode 100644 index 0000000..0e8b8f7 --- /dev/null +++ b/asset_dev/particles/bubble.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b3e935aa80bf5ef85b06e8417a0b948048e55da532dffb3e4d791751009cf9a +size 627 diff --git a/asset_dev/particles/bubble.xcf b/asset_dev/particles/bubble.xcf new file mode 100644 index 0000000000000000000000000000000000000000..d0f78ed3fb8c7388c4fe97ad865d9c81e23d42c2 GIT binary patch literal 1227 zcmds$&u-H|5XQ&emX<)pp8_Wi3lu3mL`o#Y6{$WT4oJL0>^RO!PF&e8w70&1B~Cm8 zmUxd`xgq-fIJVw zA+&$;nTUmW1noe#peH?Z-DBtqI!JKqQIsv0@v6j{IQcNh<7pYsB8_E{rD}FO7|xR@OS4=K%{0oBa4N^;eo@_;X4lBb@;&HdtiP-8+!o$ z4Zi=&o-xr8vqoTk;jldz_PLPa@XZT${O6SQHGX%bx}@z6d%pJdIELPOm-PCGX#?6A z(je^;>aCx9wHKa+VH)#Yd>#=0Q;S9SN_G@KEMc~7=vyrKKWW3}u-@S#VZtL3_@o0t z*8v5zUi void: _zones.push_back(zone) + + if zone.water_hazard: + effects.play_splash() + # Play effect but don't emit signal + # Also don't play SFX -- kind of annoying tbh diff --git a/src/equipment/balls/physics_ball/ball_particle_effects.gd b/src/equipment/balls/physics_ball/ball_particle_effects.gd index 8d88a51..86f6ac5 100644 --- a/src/equipment/balls/physics_ball/ball_particle_effects.gd +++ b/src/equipment/balls/physics_ball/ball_particle_effects.gd @@ -1,11 +1,19 @@ class_name BallParticleEffects extends Node3D ## Controller for ball particle effects. +@export var splash_effect_scene: PackedScene + @onready var sand_particles: GPUParticles3D = %SandParticles @onready var ball: GameBall = $".." +func play_splash() -> void: + var effect: Node3D = splash_effect_scene.instantiate() + ball.add_sibling(effect) + effect.global_position = ball.global_position + + func play_effect(terrain: Terrain.Type) -> void: global_rotation = Vector3.ZERO match terrain: diff --git a/src/equipment/balls/physics_ball/ball_sfx.gd b/src/equipment/balls/physics_ball/ball_sfx.gd index dc723ea..067818f 100644 --- a/src/equipment/balls/physics_ball/ball_sfx.gd +++ b/src/equipment/balls/physics_ball/ball_sfx.gd @@ -10,6 +10,7 @@ const VELOCITY_ATTENUATION_SCALE := 400.0 @onready var grass_sfx_player: AudioStreamPlayer3D = %GrassSFXPlayer @onready var concrete_sfx_player: AudioStreamPlayer3D = %ConcreteSFXPlayer @onready var sand_sfx_player: AudioStreamPlayer3D = %SandSFXPlayer +@onready var splash_sfx_player: AudioStreamPlayer3D = %SplashSFXPlayer func _force_attenuated_volume() -> float: @@ -35,3 +36,7 @@ func play_sfx(terrain: Terrain.Type) -> void: _play(concrete_sfx_player) Terrain.Type.SAND: _play(sand_sfx_player) + + +func play_splash() -> void: + _play(splash_sfx_player) diff --git a/src/equipment/balls/physics_ball/game_ball.gd b/src/equipment/balls/physics_ball/game_ball.gd index 7b3d23e..6c6b0fa 100644 --- a/src/equipment/balls/physics_ball/game_ball.gd +++ b/src/equipment/balls/physics_ball/game_ball.gd @@ -152,6 +152,8 @@ func enter_zone(zone: BallZone) -> void: _zones.push_back(zone) if zone.water_hazard: + effects.play_splash() + sfx.play_splash() entered_water.emit() diff --git a/src/equipment/balls/physics_ball/physics_ball.tscn b/src/equipment/balls/physics_ball/physics_ball.tscn index e0a1b5d..293a7e6 100644 --- a/src/equipment/balls/physics_ball/physics_ball.tscn +++ b/src/equipment/balls/physics_ball/physics_ball.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=3 uid="uid://dfttci386ohip"] +[gd_scene load_steps=25 format=3 uid="uid://dfttci386ohip"] [ext_resource type="Script" path="res://src/equipment/balls/physics_ball/game_ball.gd" id="1_iwh2u"] [ext_resource type="PhysicsMaterial" uid="uid://3bih72l068ic" path="res://src/equipment/balls/physics_ball/normal_physics.tres" id="1_l23pw"] @@ -10,8 +10,10 @@ [ext_resource type="AudioStream" uid="uid://3csnnhxndt67" path="res://assets/sound/sfx/ball/concrete5.wav" id="9_p0lmw"] [ext_resource type="AudioStream" uid="uid://bbbp6wrkuhkek" path="res://assets/sound/sfx/ball/sand1.wav" id="10_b64mx"] [ext_resource type="AudioStream" uid="uid://b5xx5t050i4p" path="res://assets/sound/sfx/ball/sand2.wav" id="11_ed8je"] +[ext_resource type="AudioStream" uid="uid://dutumw1vj854w" path="res://assets/sound/sfx/ball/splash1.wav" id="11_xmj6n"] [ext_resource type="Script" path="res://src/equipment/balls/physics_ball/ball_particle_effects.gd" id="12_7krl6"] [ext_resource type="Texture2D" uid="uid://c47bkx508biqr" path="res://assets/sprites/particles/plasma.png" id="12_guipt"] +[ext_resource type="PackedScene" uid="uid://cm4bb3lg4mfd2" path="res://src/world/effects/splash/splash_effect.tscn" id="12_qlrvx"] [sub_resource type="SphereMesh" id="SphereMesh_y0d13"] material = ExtResource("3_rc7m1") @@ -95,6 +97,11 @@ streams_count = 2 stream_0/stream = ExtResource("10_b64mx") stream_1/stream = ExtResource("11_ed8je") +[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_nlbkf"] +playback_mode = 1 +streams_count = 1 +stream_0/stream = ExtResource("11_xmj6n") + [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_mwiw1"] angle_min = -720.0 angle_max = 720.0 @@ -176,6 +183,12 @@ unit_size = 40.0 max_db = 0.0 bus = &"SFX" +[node name="SplashSFXPlayer" type="AudioStreamPlayer3D" parent="SFX"] +unique_name_in_owner = true +stream = SubResource("AudioStreamRandomizer_nlbkf") +unit_size = 40.0 +bus = &"SFX" + [node name="ManualSleepTimer" type="Timer" parent="."] unique_name_in_owner = true one_shot = true @@ -187,6 +200,7 @@ one_shot = true [node name="ParticleEffects" type="Node3D" parent="."] unique_name_in_owner = true script = ExtResource("12_7krl6") +splash_effect_scene = ExtResource("12_qlrvx") [node name="SandParticles" type="GPUParticles3D" parent="ParticleEffects"] unique_name_in_owner = true diff --git a/src/world/effects/splash/splash_effect.tscn b/src/world/effects/splash/splash_effect.tscn new file mode 100644 index 0000000..57c6de6 --- /dev/null +++ b/src/world/effects/splash/splash_effect.tscn @@ -0,0 +1,265 @@ +[gd_scene load_steps=25 format=3 uid="uid://cm4bb3lg4mfd2"] + +[ext_resource type="Texture2D" uid="uid://bogj6pvl2a7d" path="res://assets/sprites/particles/light_03.png" id="1_xmlec"] +[ext_resource type="Texture2D" uid="uid://67r5iwexjlsc" path="res://assets/sprites/particles/dot.png" id="2_tcvw8"] +[ext_resource type="Texture2D" uid="uid://bjnil2wvvf35q" path="res://assets/sprites/particles/bubble.png" id="3_jouu7"] + +[sub_resource type="Curve" id="Curve_tw8s6"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.5, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_pa3gt"] +curve = SubResource("Curve_tw8s6") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_vx5ug"] +direction = Vector3(0, 1, 0) +initial_velocity_min = 4.0 +initial_velocity_max = 4.0 +alpha_curve = SubResource("CurveTexture_pa3gt") + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ik45x"] +transparency = 1 +cull_mode = 2 +shading_mode = 0 +vertex_color_use_as_albedo = true +albedo_color = Color(0.78, 0.930333, 1, 1) +albedo_texture = ExtResource("2_tcvw8") +texture_filter = 2 +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 1 +particles_anim_v_frames = 1 +particles_anim_loop = false + +[sub_resource type="QuadMesh" id="QuadMesh_kmdkq"] +material = SubResource("StandardMaterial3D_ik45x") +size = Vector2(0.02, 0.02) + +[sub_resource type="Curve" id="Curve_ul71f"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.75, 1), 0.0, 0.0, 0, 0, Vector2(0.751, 0), 0.0, 0.0, 0, 0, Vector2(0.8, 0), 0.0, 0.0, 0, 0, Vector2(0.801, 0.8), 0.0, 0.0, 0, 0, Vector2(0.85, 0.8), 0.0, 0.0, 0, 0, Vector2(0.851, 0), 0.0, 0.0, 0, 0, Vector2(0.9, 0), 0.0, 0.0, 0, 0, Vector2(0.901, 0.6), 0.0, 0.0, 0, 0, Vector2(0.95, 0.6), 0.0, 0.0, 0, 0, Vector2(0.951, 0), 0.0, 0.0, 0, 0] +point_count = 11 + +[sub_resource type="CurveTexture" id="CurveTexture_3sk7y"] +curve = SubResource("Curve_ul71f") + +[sub_resource type="Curve" id="Curve_p2m8m"] + +[sub_resource type="Curve" id="Curve_vydb8"] +_data = [Vector2(0, 1), 0.0, -2.42919, 0, 0, Vector2(0.250526, 0.0845791), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Curve" id="Curve_yflu4"] + +[sub_resource type="CurveXYZTexture" id="CurveXYZTexture_ctsfi"] +curve_x = SubResource("Curve_p2m8m") +curve_y = SubResource("Curve_vydb8") +curve_z = SubResource("Curve_yflu4") + +[sub_resource type="Curve" id="Curve_n4ky6"] +min_value = -2.0 +max_value = 2.0 +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Curve" id="Curve_mvwav"] +min_value = -2.0 +max_value = 2.0 +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Curve" id="Curve_15euc"] +min_value = -2.0 +max_value = 2.0 +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveXYZTexture" id="CurveXYZTexture_4bki0"] +curve_x = SubResource("Curve_n4ky6") +curve_y = SubResource("Curve_mvwav") +curve_z = SubResource("Curve_15euc") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_v0h0y"] +lifetime_randomness = 0.33 +direction = Vector3(0, 1, 0) +spread = 30.0 +initial_velocity_min = 0.3 +initial_velocity_max = 0.3 +directional_velocity_min = 1.0 +directional_velocity_max = 1.0 +directional_velocity_curve = SubResource("CurveXYZTexture_ctsfi") +orbit_velocity_min = 0.5 +orbit_velocity_max = 2.0 +orbit_velocity_curve = SubResource("CurveXYZTexture_4bki0") +gravity = Vector3(0, 0, 0) +alpha_curve = SubResource("CurveTexture_3sk7y") + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_l1irr"] +transparency = 1 +cull_mode = 2 +shading_mode = 0 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("3_jouu7") +texture_filter = 2 +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 1 +particles_anim_v_frames = 1 +particles_anim_loop = false + +[sub_resource type="QuadMesh" id="QuadMesh_lvunc"] +material = SubResource("StandardMaterial3D_l1irr") +size = Vector2(0.1, 0.1) + +[sub_resource type="Animation" id="Animation_ifddj"] +resource_name = "effect" +length = 2.0 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Decal:size") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 2), +"transitions": PackedFloat32Array(0.382, 1), +"update": 0, +"values": [Vector3(0, 4, 0), Vector3(4, 4, 4)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Decal:modulate") +tracks/1/interp = 2 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 2), +"transitions": PackedFloat32Array(0.618, 1), +"update": 0, +"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("SprayParticles:emitting") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("BubbleParticles:emitting") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/4/type = "method" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath(".") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(2), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"queue_free" +}] +} + +[sub_resource type="Animation" id="Animation_mg6va"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Decal:size") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(2, 4, 2)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Decal:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("SprayParticles:emitting") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("BubbleParticles:emitting") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_87fye"] +_data = { +"RESET": SubResource("Animation_mg6va"), +"effect": SubResource("Animation_ifddj") +} + +[node name="SplashEffect" type="Node3D"] + +[node name="Decal" type="Decal" parent="."] +size = Vector3(2, 4, 2) +texture_albedo = ExtResource("1_xmlec") + +[node name="SprayParticles" type="GPUParticles3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0) +emitting = false +lifetime = 0.6 +one_shot = true +explosiveness = 0.9 +process_material = SubResource("ParticleProcessMaterial_vx5ug") +draw_pass_1 = SubResource("QuadMesh_kmdkq") + +[node name="BubbleParticles" type="GPUParticles3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0) +emitting = false +amount = 2 +lifetime = 3.0 +one_shot = true +explosiveness = 0.8 +process_material = SubResource("ParticleProcessMaterial_v0h0y") +draw_pass_1 = SubResource("QuadMesh_lvunc") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_87fye") +} +autoplay = "effect"