Godot Version
Godot 4
Question
So here is how its supposed to work. We have the enemy’s position aka enemy.slot
and the player position which is just slot
.
So the game is turned based and I want the player to walk up to the enemy and attack before going back to where they originally were. So I’m using tweens for that bit.
Here is where the problem begins. The player’s normal attack animation plays before it walks up to the enemy and I don’t know why. Here is my code:
func _on_nrml_atk_pressed(): #detects when a button is pressed
if GlobalSignals.isplayerturn == true and self == GlobalSignals.activeplayercard:
var tween : Tween = get_tree().create_tween() # Creates tween
_move_to(tween, target_enemy.slot)
tween.connect("finished", Callable(self, "_nrml_atk")) #Calls nrml atk function
representitive_node.get_node("Animations").play("NrmlAtk") # Plays animation
representitive_node.get_node("Animations").queue("Idle") # Returns to default animation after finishing.
_move_to(tween, slot) # Returns to original position
#Returns to enemy's turn
await get_tree().create_timer(1.0).timeout #if there is a way to make it return to the enemy's turn when the tween is finished let me know :)
GlobalSignals.isplayerturn = false