batrix/scripts/effects/player_attack_effect.gd

27 lines
651 B
GDScript

extends MeshInstance3D
@export var _swoop_effect_time: float = 0.25
var _swoop_effect_timer: float
@onready var _attack: PlayerAttack = $"../../Attack" as PlayerAttack
func _ready() -> void:
mesh.radius = _attack.attack_radius
mesh.height = _attack.attack_radius
_attack.attacked.connect(_on_attack_attacked)
func _process(delta: float) -> void:
if _swoop_effect_timer > 0:
_swoop_effect_timer -= delta
(material_override as StandardMaterial3D).albedo_color = Color(
1, 1, 1, _swoop_effect_timer / _swoop_effect_time
)
visible = _swoop_effect_timer > 0
func _on_attack_attacked() -> void:
_swoop_effect_timer = _swoop_effect_time