You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
612 B
GDScript
33 lines
612 B
GDScript
extends Decal
|
|
class_name ParticleDecal
|
|
|
|
@export var lifetime: float = 1
|
|
@export var gradient: Gradient
|
|
@export var scale_curve: Curve
|
|
@export var particle_rotate: int
|
|
|
|
var lifetime_now: float
|
|
|
|
|
|
func on_process(delta: float) -> void:
|
|
lifetime_now += delta
|
|
var rate: float = lifetime_now / lifetime
|
|
if rate > 1:
|
|
return
|
|
|
|
#色带
|
|
if gradient:
|
|
modulate = gradient.sample(rate)
|
|
else:
|
|
modulate.a = 1 - rate
|
|
|
|
#缩放曲线
|
|
if scale_curve:
|
|
var scale_sample: float = scale_curve.sample(rate)
|
|
scale = Vector3(scale_sample, 1, scale_sample)
|
|
|
|
#旋转
|
|
rotation_degrees.y = particle_rotate * rate
|
|
return
|
|
|