feat(vfx): animate movement and scoring effects

This commit is contained in:
Josh Creek
2026-08-07 22:31:17 +01:00
parent 8d4078989c
commit 78ef0cb1f8
4 changed files with 225 additions and 1 deletions
+42
View File
@@ -26,6 +26,8 @@ const RIM_DEPTH := 0.05
const NET_SHADER_PATH := "res://shaders/goal_net.gdshader"
var _goal_burst: GPUParticles3D
func _ready():
# Group lets AI controllers and game modes discover goals
@@ -34,10 +36,13 @@ func _ready():
# headless arenas that never render it. The sensor is unaffected.
if DisplayServer.get_name() != "headless":
_build_visuals()
_build_goal_burst()
func _on_body_entered(body):
if body.is_in_group("ball"):
if _goal_burst:
_goal_burst.restart()
goal_scored.emit(team)
@@ -103,6 +108,43 @@ func _build_visuals() -> void:
add_child(visuals)
func _build_goal_burst() -> void:
var tint: Color = TeamColors.TEAM_COLORS[team % TeamColors.TEAM_COLORS.size()]
var mat := StandardMaterial3D.new()
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
mat.billboard_mode = BaseMaterial3D.BILLBOARD_ENABLED
mat.albedo_color = Color(tint.r, tint.g, tint.b, 0.9)
mat.emission_enabled = true
mat.emission = tint
mat.emission_energy_multiplier = 3.0
var quad := QuadMesh.new()
quad.size = Vector2(0.38, 0.8)
quad.material = mat
var process := ParticleProcessMaterial.new()
process.emission_shape = ParticleProcessMaterial.EMISSION_SHAPE_BOX
process.emission_box_extents = Vector3(1.7, 0.7, 0.15)
process.direction = Vector3(0, 0, -1)
process.spread = 48.0
process.initial_velocity_min = 8.0
process.initial_velocity_max = 18.0
process.gravity = Vector3(0, -2.0, 0)
process.scale_min = 0.35
process.scale_max = 1.2
_goal_burst = GPUParticles3D.new()
_goal_burst.name = "GoalBurst"
_goal_burst.position = Vector3(0, 0, -0.15)
_goal_burst.amount = 140
_goal_burst.lifetime = 1.1
_goal_burst.one_shot = true
_goal_burst.explosiveness = 0.92
_goal_burst.process_material = process
_goal_burst.draw_pass_1 = quad
_goal_burst.visibility_aabb = AABB(Vector3(-12, -8, -20), Vector3(24, 16, 24))
_goal_burst.emitting = false
add_child(_goal_burst)
# Four bars around the mouth. The uprights run the full outer height so each
# corner is covered exactly once.
func _add_frame_ring(