extends "res://Scripts/animationBase.gd" var path: PathFollow2D var failPath: PathFollow2D var casting: bool = true var timer: float = 0 @onready var texture: TextureRect = $Path2D/PathFollow2D/TextureRect # Called when the node enters the scene tree for the first time. func _ready(): if !inverted: path = $Path2D/PathFollow2D failPath = $Path2D/PathFollow2D/Path2D/PathFollow2D # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if casting: if targetProg / finalProg < 0.7: timer = clampf(timer + delta, 0, clampf(targetProg / finalProg, 0, 0.35)) path.progress_ratio = timer else: timer = clampf(timer + delta, 0, 1) path.progress_ratio = timer if path.progress_ratio == 1: self.free() else: timer = clampf(timer + (1.25 * delta), 0, 1) failPath.progress_ratio = timer if failPath.progress_ratio == 1: self.free() func castFailed() -> void: casting = false texture.get_parent().remove_child(texture) failPath.add_child(texture) timer = 0