0 votes

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()
#-------------------------------------------------------------------------------
Godot version 3.4.4
in Engine by (12 points)

1 Answer

+1 vote

You can't force animationplayer to play in process(), because it starts animation from first frame once every process frame ! Your animationplayer works, but is frozen in frame 0. You need to design a way to activate play() once, just like ready() function is activated once

by (5,651 points)

Any advice on how to do that? I'm very new to Godot and would need more experience to figure out how to do that on my own.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.