Godot4.7
I don’t know how to do a combo attack.
I’ve been trying to add a combo system to my top down perspective game for over a week now and I’m at my wits end. Every guide or forum post that I’ve found only seem to edge me to a solution that i cant reach and it’s driving me mad.
I’d really appreciate some help here, I tried to trim down the code into only the relevant portions. This is an extended script based on an earlier instance of the player character if that helps, though the earlier instance can only use 1 attack and this is supposed to be an upgrade that the player gets halfway through the game. I’m also using an AnimationTree as a state machine and i have no clue if that’s good or not.
func _physics_process(delta: float) -> void:
var state = playback.get_current_node()
match state:
"MoveState": move_state(delta)
"Attack1": pass
func move_state(_delta: float) -> void:
input_vector = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
if input_vector != Vector2.ZERO:
last_input_vector = input_vector
var direction_vector: = Vector2(input_vector.x, -input_vector.y)
update_blend_position(direction_vector)
if Input.is_action_just_pressed("Attack"):
playback.travel("Attack1")
combo_timer.start()
if Input.is_action_just_pressed("Attack") && combo_timer.is_stopped():
combo_timer.start()
playback.travel("Attack2")
if Input.is_action_just_pressed("Attack") && combo_timer.is_stopped():
combo_timer.start()
playback.travel("Attack3")
if Input.is_action_just_pressed("Attack") && combo_timer.is_stopped():
combo_timer.start()
playback.travel("Attack4")
func update_blend_position(direction_vector: Vector2) -> void:
animation_tree.set("parameters/StateMachine/MoveState/MoveState/blend_position", direction_vector)
animation_tree.set("parameters/StateMachine/MoveState/StandState/blend_position", direction_vector)
animation_tree.set("parameters/StateMachine/Attack1/blend_position", direction_vector)
animation_tree.set("parameters/StateMachine/Attack2/blend_position", direction_vector)
animation_tree.set("parameters/StateMachine/Attack3/blend_position", direction_vector)
animation_tree.set("parameters/StateMachine/Attack4/blend_position", direction_vector)