#Combo attack

10 messages · Page 1 of 1 (latest)

jovial hull
#

im trying to make a combo system with state machine but the delay of the first attack is not working properly, if i add attacking == false it doesnt transition to the second attack. Also the animationplayer is changing attacking to false at the end of the animation

extends NodeState

@export var character_body_2d: CharacterBody2D
@export var animation_player: AnimationPlayer
@export var attacking = false
@export var can_combo = false


func _on_process(_delta : float) -> void:
    pass
        
        
func _on_physics_process(_delta : float) -> void:
    pass


func _on_next_transitions() -> void:
    if GameInputEvents.attack_input() and can_combo == true:
        transition.emit("Attack2")
        
    if character_body_2d.is_on_floor() and attacking == false:
        transition.emit("Idle")
    
    elif not character_body_2d.is_on_floor() and attacking == false:
        transition.emit("Fall")


func _on_enter() -> void:
    attacking = true
    animation_player.play("attack_up")
    combo_timer()

func _on_exit() -> void:
    animation_player.stop()
    

func combo_timer():
    can_combo = true
    await get_tree().create_timer(1.0).timeout
    can_combo = false
crystal idol
#

Where are you adding attacking == false?

jovial hull
#

func _on_next_transitions() -> void:
if GameInputEvents.attack_input() and can_combo == true and attacking == false:
transition.emit("Attack2")

crystal idol
#

How long is the attack animation?

jovial hull
crystal idol
#

Looks like it should work. Can you verify that attacking is true for the duration of the first attack animation?

jovial hull
#

yeah, i think its bc attacking is false for like a frame

crystal idol
#

That frame is what causes the state to turn idle

#

Hmm

jovial hull
#

yeah, ill try something and see if it works