2024-12-04 19:06:18 -07:00
|
|
|
class_name BallParticleEffects extends Node3D
|
|
|
|
## Controller for ball particle effects.
|
|
|
|
|
2025-01-02 15:16:49 -07:00
|
|
|
@export var splash_effect_scene: PackedScene
|
|
|
|
|
2024-12-04 19:06:18 -07:00
|
|
|
@onready var sand_particles: GPUParticles3D = %SandParticles
|
|
|
|
|
|
|
|
@onready var ball: GameBall = $".."
|
|
|
|
|
|
|
|
|
2025-01-02 15:16:49 -07:00
|
|
|
func play_splash() -> void:
|
|
|
|
var effect: Node3D = splash_effect_scene.instantiate()
|
|
|
|
ball.add_sibling(effect)
|
|
|
|
effect.global_position = ball.global_position
|
|
|
|
|
|
|
|
|
2024-12-04 19:06:18 -07:00
|
|
|
func play_effect(terrain: Terrain.Type) -> void:
|
|
|
|
global_rotation = Vector3.ZERO
|
|
|
|
match terrain:
|
|
|
|
Terrain.Type.SAND:
|
|
|
|
# Adjust sand particle direction
|
|
|
|
var material: ParticleProcessMaterial = sand_particles.process_material
|
|
|
|
material.direction = -ball.linear_velocity.normalized()
|
|
|
|
sand_particles.emitting = true
|