add final godrays
This commit is contained in:
43
GodrayBurst.gd
Normal file
43
GodrayBurst.gd
Normal file
@@ -0,0 +1,43 @@
|
||||
extends MeshInstance3D
|
||||
|
||||
@export var life_time: float = 8.0 # Quanto dura l'intera animazione di movimento/intensità in secondi
|
||||
# --- NUOVI PARAMETRI PER L'APPARIZIONE MORBIDA ---
|
||||
@export var fade_in_time: float = 4.0 # Quanti secondi ci mette ad apparire dolcemente
|
||||
@export var max_base_alpha: float = 1.0 # Il valore massimo a cui arriva l'alpha (se 1.0 è troppo forte, abbassalo qui)
|
||||
|
||||
func _ready():
|
||||
# Duplichiamo il materiale per renderlo unico per questo specifico raggio
|
||||
var mat = get_active_material(0).duplicate()
|
||||
set_surface_override_material(0, mat)
|
||||
|
||||
add_to_group("camere")
|
||||
|
||||
# IMPORTANTE: Impostiamo subito l'alpha a 0 prima che il gioco faccia il primo frame,
|
||||
# così evitiamo il fastidioso "pop" visivo iniziale.
|
||||
mat.set_shader_parameter("base_alpha", 0.0)
|
||||
|
||||
# Avvia le animazioni
|
||||
animate_godray(mat)
|
||||
|
||||
func animate_godray(mat: ShaderMaterial):
|
||||
# --- 1. NUOVA ANIMAZIONE: FADE IN DEL BASE ALPHA ---
|
||||
var tween_alpha = create_tween()
|
||||
# In fade_in_time secondi (es. 2), porta base_alpha da 0.0 a max_base_alpha (es. 1.0)
|
||||
tween_alpha.tween_property(mat, "shader_parameter/base_alpha", max_base_alpha, fade_in_time).from(0.0)
|
||||
|
||||
|
||||
# --- 2. VECCHIE ANIMAZIONI: INTENSITA' E BORDI ---
|
||||
var tween_intensity = create_tween()
|
||||
# Imposta il valore iniziale a 1.0 e scende a 0.2
|
||||
tween_intensity.tween_property(mat, "shader_parameter/intensity_multiplier", 0.2, life_time * 0.3).from(1.0)
|
||||
# Sale a 0.5
|
||||
tween_intensity.tween_property(mat, "shader_parameter/intensity_multiplier", 0.5, life_time * 0.3)
|
||||
# Scende a 0.0 (che lo fa sparire dolcemente alla fine)
|
||||
tween_intensity.tween_property(mat, "shader_parameter/intensity_multiplier", 0.0, life_time * 0.4)
|
||||
|
||||
# Quando l'intensità arriva a 0 alla fine del suo ciclo vitale, elimina questo godray
|
||||
tween_intensity.tween_callback(queue_free)
|
||||
|
||||
var tween_edge = create_tween()
|
||||
tween_edge.tween_property(mat, "shader_parameter/edge_fade_power", 0.5, life_time * 0.5).from(2.0)
|
||||
tween_edge.tween_property(mat, "shader_parameter/edge_fade_power", 2.0, life_time * 0.5)
|
||||
Reference in New Issue
Block a user