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

2 years ago
extends Decal
class_name ParticleDecal
2 years ago
@export var lifetime: float = 1
@export var gradient: Gradient
@export var scale_curve: Curve
@export var particle_rotate: int
2 years ago
2 years ago
var lifetime_now: float
2 years ago
2 years ago
func on_process(delta: float) -> void:
2 years ago
lifetime_now += delta
2 years ago
var rate: float = lifetime_now / lifetime
2 years ago
if rate > 1:
return
2 years ago
2 years ago
#色带
if gradient:
modulate = gradient.sample(rate)
else:
modulate.a = 1 - rate
2 years ago
2 years ago
#缩放曲线
if scale_curve:
2 years ago
var scale_sample: float = scale_curve.sample(rate)
scale = Vector3(scale_sample, 1, scale_sample)
2 years ago
#旋转
2 years ago
rotation_degrees.y = particle_rotate * rate
return
2 years ago