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.
|
|
|
|
extends EffectBase
|
|
|
|
|
class_name Afterimage
|
|
|
|
|
|
|
|
|
|
@export var is_moving: bool = true
|
|
|
|
|
|
|
|
|
|
@onready var image: AnimatedSprite3D = $AnimatedSprite3D as AnimatedSprite3D
|
|
|
|
|
|
|
|
|
|
var velocity: Vector3
|
|
|
|
|
var target: AnimatedSprite3D
|
|
|
|
|
var alpha: float
|
|
|
|
|
var material: ShaderMaterial
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_ready():
|
|
|
|
|
if not target or not target.sprite_frames:
|
|
|
|
|
queue_free()
|
|
|
|
|
return
|
|
|
|
|
image.sprite_frames = target.sprite_frames
|
|
|
|
|
image.animation = target.animation
|
|
|
|
|
image.frame = target.frame
|
|
|
|
|
image.frame_progress = target.frame_progress
|
|
|
|
|
image.scale.x = target.scale.x
|
|
|
|
|
image.pixel_size = Setting.pixel_size
|
|
|
|
|
material = ResourceManager.material_after_image.duplicate()
|
|
|
|
|
image.material_override = material
|
|
|
|
|
update_material()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_process(delta):
|
|
|
|
|
if is_moving:
|
|
|
|
|
position += velocity*delta
|
|
|
|
|
# image.modulate.a = rate * alpha
|
|
|
|
|
update_material()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func update_material() -> void:
|
|
|
|
|
if material and image.sprite_frames and image.animation:
|
|
|
|
|
var tex: Texture2D = image.sprite_frames.get_frame_texture(image.animation, image.frame)
|
|
|
|
|
material.set_shader_parameter("tex", tex)
|
|
|
|
|
material.set_shader_parameter("alpha", rate * alpha)
|