- Edited
I've looked around searching an example on how to make a fighter game input like street fighter or tekken, and i've figured some of it out but im still having trouble on how to know when the player puts a series of inputs. Heres my code:
var input_buffer = []
var input_buffer_max_size = 5
var input_previous_buffer = "N"
var input_angle = ""
func input_movement():
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized()
if input_direction.length() < 0.2:
input_angle = "N"
if input_direction.x != 0 || input_direction.x >= 0:
if input_direction.y < 0:
input_angle = "8"
if input_direction.x > 0:
input_angle = "9"
elif input_direction.x < 0:
input_angle = "7"
elif input_direction.y > 0:
input_angle = "2"
if input_direction.x > 0:
input_angle = "3"
elif input_direction.x < 0:
input_angle = "1"
elif input_direction.x > 0:
input_angle = "6"
elif input_direction.x < 0:
input_angle = "4"
func handle_attack_input():
if input_angle != input_previous_buffer:
input_buffer.push_back(input_angle)
input_previous_buffer = input_angle
if input_buffer.size() > input_buffer_max_size:
input_buffer = input_buffer.slice(input_buffer.size() - input_buffer_max_size, input_buffer.size())
func check_moves():
if input_buffer.find("2, 3") > -1:
print_debug("COMBO WORKED")
I have the input_angle set to numbers as like on a numpad with "5" on the numpad being "N" or neutral and "8" being up and so on. If i try printing the array called input buffer, it does work as i want (OUTPUT):
(6) ["3", "2", "N", "2", "3"]
but its not printing when im trying to find the series of inputs. How can i fix this? Thanks.