0 votes

Hey everyone, currently I'm following a action rpg tutorial from a youtuber. Everything was going fine until i kinda messed with something unknowingly when i was showcasing my friends how the animationtree works. When i press any walking key the character walks for 1 animation loop. after the frames are over and it should repeat the animation, it doesnt. It stops at the last frame. Until i change the state to roll or attack it walks with the stuck frame. Does anyone know where i messed up with? I will share the script but i know that wasn't something i touched. Thank you!

A gif from the game.

Here is the player script.

extends KinematicBody2D

const acc = 500
const max_speed = 100
const friction = 500
const roll_speed = 125


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

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

func _ready():
    animationTree.active = true

func _physics_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
        animationTree.set("parameters/Idle/blend_position", input_vector)
        animationTree.set("parameters/walk/blend_position", input_vector)
        animationTree.set("parameters/Attack/blend_position", input_vector)
        animationTree.set("parameters/Roll/blend_position", input_vector)
        velocity = velocity.move_toward(input_vector*max_speed, acc*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

func roll_state(delta):
    velocity = roll_vector * roll_speed

func attack_state(delta):
    velocity = Vector2.ZERO

func move():
    velocity = move_and_slide(velocity)

func roll_animation_finished():
    velocity = Vector2.ZERO
    state = MOVE

func attack_animation_finished():
    state = MOVE
Godot version Godot 3.2.3 Stable
in Engine by (12 points)

1 Answer

+1 vote

Is Animation Looping enabled for the walking animation?

The "Animation Looping" button is in the top right corner of the Animation bottom panel. If it's blue, then Animation Looping is enabled.

by (365 points)

Ah, yes so that was the problem. Thank you for reminding me!

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 Frequently asked questions and 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 [email protected] with your username.