make separate player attack effect class

This commit is contained in:
2025-02-27 04:00:47 +10:00
parent 4920bcaa16
commit cedce3eef8
4 changed files with 48 additions and 33 deletions

View File

@@ -0,0 +1,26 @@
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