Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Onulator |
I’ve been looking into this for about a week or two now, and I still have no idea what’s going wrong. Basically, I’ve set up the animation player with 3 animations to activate on certain button presses in the process function, but when opening the debugger, it doesn’t work. And yet if I set it to loop and have it start up immediately in the ready function, it works properly. No matter what I do, what tutorial I look up, anything, I can’t get it to work, even though I’m pretty sure I’m using the correct code.
Am I just missing something or what?
extends KinematicBody2D
onready var P1_Animations = $P1_Animations
var isInCombo = false
var timeTillNextInput = 0.5
var time = 0
var currentAttack = 0
var previousAttack = 0
#-------------------------------------------------------------------------------
func _ready(): #Loads on startup
time = timeTillNextInput
#-------------------------------------------------------------------------------
func _proccess(delta): #Game checks all of this every frame
if(Input.is_action_just_pressed("P1_Attack1")):
if(currentAttack == 0):
P1_Animations.play("N-Attack1-1")
elif (currentAttack == 1):
P1_Animations.play("N-Attack1-2")
isInCombo = true
currentAttack += 1
if(isInCombo):
time -= delta
if(time < 0):
time = timeTillNextInput
isInCombo = false
currentAttack = 0
P1_Animations.play("RESET")
if Input.is_action_pressed("ui_right"):
$P1_Animations.play("N-Attack1-1")
else:
$P1_Animations.stop()
#-------------------------------------------------------------------------------