How can i make a second, third, fourth, etc. attack in my 2D game?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Marmorplatte

Im making a 2D RPG game… You can move around in a open world. So i made a attack (with a sword) but im not sure how to make a second attack. I’m planning to do a magic spell as my second attack but i can’t find out how. The animation is already finished and i already set it up in the AnimationPlayer + AnimationTree. In my player script logically it have to work, but when I press the button for the second attack (Key “2”) the player just freezes…

Here is my player-code:

extends KinematicBody2D

export var ACCELERATION = 500
export var MAX_SPEED = 80
export var ROLL_SPEED = 110
export var FRICTION = 500

enum {

var state = MOVE
var velocity = Vector2.ZERO
var roll_vector = Vector2.DOWN

onready var animationPlayer = $AnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")
onready var swordHitbox = $Position2D/SwordHitbox

func _ready(): = true
	swordHitbox.knockback_vector = roll_vector

func _process(delta):
	match state:
func move_state(delta):
	var input_vector = Vector2.ZERO
	input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
	input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
	input_vector = input_vector.normalized()
	if input_vector != Vector2.ZERO:
		roll_vector = input_vector
		swordHitbox.knockback_vector = input_vector
		animationTree.set("parameters/Idle/blend_position", input_vector)
		animationTree.set("parameters/Run/blend_position", input_vector)
		animationTree.set("parameters/Attack/blend_position", input_vector)
		animationTree.set("parameters/Attack2/blend_position", input_vector)
		animationTree.set("parameters/Roll/blend_position", input_vector)"Run")
		velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
		velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
	if Input.is_action_just_pressed("roll"):
		state = ROLL
	if Input.is_action_just_pressed("attack"):
		state = ATTACK
	if Input.is_action_just_pressed("attack2"):
		state = ATTACK2

func roll_state(delta):
	velocity = roll_vector * ROLL_SPEED"Roll")

func attack_state(_delta):
	velocity = Vector2.ZERO"Attack")

func attack2_state(_delta):
	velocity = Vector2.ZERO"Attack2")

func move():
	velocity = move_and_slide(velocity)

func roll_animation_finished():
	velocity =  velocity / 2
	state = MOVE

func attack_animation_finished():
	state = MOVE

func attack2_animation_finished():
	state = MOVE
:bust_in_silhouette: Reply From: Bot7

I dont know if you mean combo. When you mean combos this video should help you

Unfortunately I don’t mean combos… I mean I want to have a second attack (a attack which is completely different than the first meele attack)…

Marmorplatte | 2021-02-05 23:31