0
\$\begingroup\$

I intend to make a combo system like Devil May Cry 3 (meaning, combo attacks like E-E-E, or E-(pause)-E-E, and directional attacks like forward+E or backward+E, assuming E is the melee attack button). Right now my pseudocode for the first combo is the following:

var combo_frames = 60
var hitbox_show_frame = 24
var pause_threshold = 45
var hitbox_show_dur_in_frames = 6
var hitbox_consumed = false
var current_frame = 0
var hitbox_show_curr_frame = 0

func _physics_process(delta): #Godot2D's fixedUpdate()
    current_frame += 1
    if current_frame >= hitbox_show_frame and not hitbox_consumed:
        hitbox_coll.disabled = false
        if current_frame >= hitbox_show_frame + hitbox_show_dur_in_frames:
            hitbox_coll.disabled = false
            hitbox_consumed = true
    if frame_num >= combo_frames:
        combo_index = 0
        return Melee_Idle.new()
    pass

func _input(event):
    if hitbox_consumed:
        if current_frame < pause_threshold:
            return Melee_Combo2.new() #normal combo
        elif current_frame < combo_frames:
            return Melee_Combo2_Alt.new() #alternate combo after some delay

As seen, I've implemented a Finite State Machine for the combo system.

However, I don't have the animation sprites for these combos yet, so the frame numbers are just approximations. Should I get or make said animation sprites before designing this combo system, or can I think about it later and use the frame count like above for now?

\$\endgroup\$
2
\$\begingroup\$

In my experience it's always best to not count on hard animation times, especially when you're dealing with variable input times. Try implementing a onAnimationEnd event handler of some sort to make sure your animation has actually ended before you continue with your script. Also in most engines it's possible to insert key frames in your animation that allow you to execute pieces of code. That way you don't have to worry with exact animation times and your code becomes way more flexible.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.