generated from krampus/template-godot4
38 lines
1.1 KiB
GDScript
38 lines
1.1 KiB
GDScript
class_name BallParticleEffects extends Node3D
|
|
## Controller for ball particle effects.
|
|
|
|
@export var splash_effect_scene: PackedScene
|
|
|
|
@onready var chunk_particles: GPUParticles3D = %ChunkParticles
|
|
@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 _physics_process(_delta: float) -> void:
|
|
global_rotation = Vector3.ZERO
|
|
|
|
|
|
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.current_gravity.normalized()
|
|
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
|