Particle effect when chunking shot

This commit is contained in:
Rob Kelly 2025-01-09 17:58:40 -07:00
parent ec1bd890f5
commit e3d0fe7f2f
6 changed files with 102 additions and 6 deletions

BIN
assets/sprites/particles/smudge.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dy310v1j5vexd"
path="res://.godot/imported/smudge.png-6be29afb408991155df57310104cb1f8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/particles/smudge.png"
dest_files=["res://.godot/imported/smudge.png-6be29afb408991155df57310104cb1f8.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@ -39,3 +39,8 @@ func _process(_delta: float) -> void:
spawn_balls(DROP_SPAWN_GROUP) spawn_balls(DROP_SPAWN_GROUP)
if Input.is_action_just_pressed("debug_3"): if Input.is_action_just_pressed("debug_3"):
spawn_balls(PUTT_SPAWN_GROUP, PUTT_VEC) spawn_balls(PUTT_SPAWN_GROUP, PUTT_VEC)
if Input.is_action_just_pressed("ui_page_up"):
Engine.time_scale *= 2.0
if Input.is_action_just_pressed("ui_page_down"):
Engine.time_scale *= 0.5

View File

@ -3,6 +3,7 @@ class_name BallParticleEffects extends Node3D
@export var splash_effect_scene: PackedScene @export var splash_effect_scene: PackedScene
@onready var chunk_particles: GPUParticles3D = %ChunkParticles
@onready var sand_particles: GPUParticles3D = %SandParticles @onready var sand_particles: GPUParticles3D = %SandParticles
@onready var ball: GameBall = $".." @onready var ball: GameBall = $".."
@ -14,11 +15,23 @@ func play_splash() -> void:
effect.global_position = ball.global_position effect.global_position = ball.global_position
func _physics_process(_delta: float) -> void:
global_rotation = Vector3.ZERO
func play_effect(terrain: Terrain.Type) -> void: func play_effect(terrain: Terrain.Type) -> void:
global_rotation = Vector3.ZERO global_rotation = Vector3.ZERO
match terrain: match terrain:
Terrain.Type.SAND: Terrain.Type.SAND:
# Adjust sand particle direction # Adjust sand particle direction
var material: ParticleProcessMaterial = sand_particles.process_material var material: ParticleProcessMaterial = sand_particles.process_material
material.direction = -ball.linear_velocity.normalized() material.direction = -ball.current_gravity.normalized()
sand_particles.emitting = true sand_particles.emitting = true
func play_chunk(chunk_scale: float) -> void:
print_debug("Playing chunk effect, scale: ", chunk_scale)
chunk_particles.amount_ratio = chunk_scale
var material: ParticleProcessMaterial = chunk_particles.process_material
material.direction = -ball.current_gravity.normalized()
chunk_particles.emitting = true

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=26 format=3 uid="uid://dfttci386ohip"] [gd_scene load_steps=30 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="Script" path="res://src/equipment/balls/physics_ball/game_ball.gd" id="1_iwh2u"]
[ext_resource type="Resource" uid="uid://c6tt1hto75ex4" path="res://src/equipment/balls/physics_ball/normal_terrain_physics.tres" id="3_3gnie"] [ext_resource type="Resource" uid="uid://c6tt1hto75ex4" path="res://src/equipment/balls/physics_ball/normal_terrain_physics.tres" id="3_3gnie"]
@ -12,8 +12,8 @@
[ext_resource type="AudioStream" uid="uid://b5xx5t050i4p" path="res://assets/sound/sfx/ball/sand2.wav" id="11_ed8je"] [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="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="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"] [ext_resource type="PackedScene" uid="uid://cm4bb3lg4mfd2" path="res://src/world/effects/splash/splash_effect.tscn" id="12_qlrvx"]
[ext_resource type="Texture2D" uid="uid://dy310v1j5vexd" path="res://assets/sprites/particles/smudge.png" id="14_el0o3"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_u134x"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_u134x"]
bounce = 0.8 bounce = 0.8
@ -105,6 +105,35 @@ playback_mode = 1
streams_count = 1 streams_count = 1
stream_0/stream = ExtResource("11_xmj6n") stream_0/stream = ExtResource("11_xmj6n")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_706cj"]
angle_min = -720.0
angle_max = 720.0
spread = 20.0
initial_velocity_min = 1.0
initial_velocity_max = 5.0
scale_min = 0.0
hue_variation_min = -0.02
hue_variation_max = -2.23517e-08
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_5u1jh"]
load_path = "res://.godot/imported/smudge.png-6be29afb408991155df57310104cb1f8.ctex"
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_fbolh"]
transparency = 1
vertex_color_use_as_albedo = true
albedo_color = Color(0.17, 0.12954, 0.0272, 1)
albedo_texture = SubResource("CompressedTexture2D_5u1jh")
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_npp3t"]
material = SubResource("StandardMaterial3D_fbolh")
size = Vector2(0.15, 0.15)
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_mwiw1"] [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_mwiw1"]
angle_min = -720.0 angle_min = -720.0
angle_max = 720.0 angle_max = 720.0
@ -119,9 +148,9 @@ hue_variation_max = -2.23517e-08
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v1i8b"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v1i8b"]
transparency = 1 transparency = 1
vertex_color_use_as_albedo = true vertex_color_use_as_albedo = true
albedo_color = Color(0.78, 0.70928, 0.5304, 1) albedo_color = Color(0.45, 0.4092, 0.306, 1)
albedo_texture = ExtResource("12_guipt") albedo_texture = ExtResource("14_el0o3")
texture_filter = 4 texture_filter = 2
billboard_mode = 3 billboard_mode = 3
billboard_keep_scale = true billboard_keep_scale = true
particles_anim_h_frames = 1 particles_anim_h_frames = 1
@ -206,6 +235,15 @@ unique_name_in_owner = true
script = ExtResource("12_7krl6") script = ExtResource("12_7krl6")
splash_effect_scene = ExtResource("12_qlrvx") splash_effect_scene = ExtResource("12_qlrvx")
[node name="ChunkParticles" type="GPUParticles3D" parent="ParticleEffects"]
unique_name_in_owner = true
emitting = false
amount = 12
one_shot = true
explosiveness = 1.0
process_material = SubResource("ParticleProcessMaterial_706cj")
draw_pass_1 = SubResource("QuadMesh_npp3t")
[node name="SandParticles" type="GPUParticles3D" parent="ParticleEffects"] [node name="SandParticles" type="GPUParticles3D" parent="ParticleEffects"]
unique_name_in_owner = true unique_name_in_owner = true
emitting = false emitting = false

View File

@ -311,6 +311,9 @@ func take_shot() -> void:
game_ball.magnetic = club_type == Club.Type.IRON game_ball.magnetic = club_type == Club.Type.IRON
game_ball.freeze = false game_ball.freeze = false
game_ball.apply_impulse(impulse, offset) game_ball.apply_impulse(impulse, offset)
if not is_shot_good():
# Play chunk particle effect
game_ball.effects.play_chunk(absf(shot_curve) / (1.0 - NICE_THRESHOLD))
reset_prompt_timer.start() reset_prompt_timer.start()