I’m currently having problems with my enemies in the game not playing their attack animations during the attack. The enemies are meant to do a start of round animation, disappear, appear at point A, dash to point B, then disappear until the next attack. However, when dashing the attack animation will not play. Code will be below:
#FIX 1 PROBLEM(S):
#1. ENEMY ANIMATIONS ARE NOT WORKING
extends Node2D
@onready var AtkTimer: Timer = $AtkTimer
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
const SPEED = 999
var AtkReady = true
var InAtk = false
var AtkPointA = 0
var AtkPointB = 0
var RoundStart = false
Called every frame. ‘delta’ is the elapsed time since the previous frame.
func _process(delta: float) → void:
print(AtkTimer.time_left)
if InAtk == true:
animated_sprite.play("Attack")
await animated_sprite.animation_finished
animated_sprite.play("Vanish")
func _input(event: InputEvent) → void:
if event is InputEventMouseButton and event.pressed:
print(AtkReady)
print(InAtk)
if AtkReady == true and InAtk == false:
if event is InputEventMouseButton and event.pressed:
var AtkTween := create_tween()
if AtkTimer.timeout:
AtkReady = true
InAtk = false
else:
AtkReady = false
InAtk = true
AtkTimer.start()
AtkTween.tween_property(self,"global_position", get_global_mouse_position() , 0.5)
if Input.is_action_just_pressed("Test Enemy switch"):
if AtkReady == false and InAtk == true:
AtkReady = true
InAtk = false
elif AtkReady == true and InAtk == false:
AtkReady = false
InAtk = true